GithubHelp home page GithubHelp logo

kryndex / api-security-checklist Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shieldfy/api-security-checklist

0.0 2.0 0.0 8 KB

Checklist of the most important security countermeasures when designing, testing, and releasing your API

License: MIT License

api-security-checklist's Introduction

API Security Checklist

Checklist of the most important security countermeasures when designing, testing, and releasing your API.


Authentication

  • Don't use Basic Auth Use standard authentication (e.g. JWT, OAuth).
  • Don't reinvent the wheel in Authentication, token generating, password storing use the standards.

JWT (JSON Web Token)

  • Use random complicated key (JWT Secret) to make brute forcing token very hard.
  • Don't extract the algorithm from the payload. Force algorithm in the backend (HS256 or RS256).
  • Make token expiration (TTL, RTTL) short as possible.
  • Don't store sensitive data in the JWT payload, it can be decoded easily.

OAuth

  • Always validate redirect_uri on server side to allow only whitelisted URLs.
  • Always try to exchange for code not tokens (don't allow response_type=token).
  • Use state parameter with a random hash to prevent CSRF on OAuth authentication process.
  • Define default scope, and validate scope parameter for each application.

Access

  • Limit requests (Throttling) to avoid DDoS / Bruteforce attacks.
  • Use HTTPS on server side to avoid MITM.
  • Use HSTS header with SSL to avoid SSL Strip attack.

Input

  • Use proper HTTP method according to operation , GET (read), POST (create), PUT (replace/update) and DELETE (to delete a record).
  • Validate content-type on request Accept header ( Content Negotiation ) to allow only your supported format (e.g. application/xml , application/json ... etc) and respond with 406 Not Acceptable response if not matched.
  • Validate content-type of posted data as you accept (e.g. application/x-www-form-urlencoded , multipart/form-data ,application/json ... etc ).
  • Validate User input to avoid common vulnerabilities (e.g. XSS, SQL-Injection , Remote Code Execution ... etc).
  • Don't use any sensitive data ( credentials , Passwords, security tokens, or API keys) in the URL, but use standard Authorization header.

Processing

  • Check if all endpoint protected behind the authentication to avoid broken authentication.
  • User own resource id should be avoided. Use /me/orders instead of /user/654321/orders
  • Don't use auto increment id's use UUID instead.
  • If you are parsing XML files, make sure entity parsing is not enable to avoid XXE.
  • Use CDN for file uploads.
  • If you are dealing with huge amount of data, use Workers and Queues to return response fast to avoid HTTP Blocking.
  • Do not forget and leave the DEBUG mode on.

Output

  • Send X-Content-Type-Options: nosniff header.
  • Send X-Frame-Options: deny header.
  • Send Content-Security-Policy: default-src 'none' header.
  • Force content-type for your response , if you return application/json then your response content-type is application/json.
  • Don't return sensitive data like credentials , Passwords, security tokens.
  • Return the proper status code according to the operation completed. (e.g. 200 OK , 400 Bad Request , 401 Unauthorized, 405 Method Not Allowed ... etc).

Contribution

Feel free to contribute , fork -> edit -> submit pull request. For any questions drop us an email at [email protected].

api-security-checklist's People

Contributors

netcode avatar homeworkprod avatar internalfx avatar darshan- avatar doug-descombaz avatar kpcyrd avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.