API Security Checklist
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 instead (e.g. JWT, OAuth).
Use a random complicated key (JWT Secret) to make brute forcing the token very
hard.
Don't extract the algorithm from the header. Force the algorithm in the backend
(HS256 or RS256).
Don't store sensitive data in the JWT payload, it can be decoded easily.
OAuth
Always try to exchange for code and not tokens (don't allow
response_type=token).
Use state parameter with a random hash to prevent CSRF on the OAuth
authentication process.
Define the default scope, and validate scope parameters for each application.
Access
Use HTTPS on server side to avoid MITM (Man in the Middle Attack).
Input
Use the proper HTTP method according to the operation: GET (read), POST
(create), PUT/PATCH (replace/update), and DELETE (to delete a record), and
respond with 405 Method Not Allowed if the requested method isn't appropriate for the
requested resource.
Don't use any sensitive data (credentials, Passwords, security tokens, or API
keys) in the URL, but use standard Authorization header.
Use an API Gateway service to enable caching, Rate Limit policies (e.g. Quota,
Spike Arrest, or Concurrent Rate Limit) and deploy APIs resources dynamically.
Processing
Check if all the endpoints are protected behind authentication to avoid broken
authentication process.
If you are parsing XML files, make sure entity parsing is not enabled to avoid XXE
(XML external entity attack).
If you are parsing XML files, make sure entity expansion is not enabled to avoid
Billion Laughs/XML bomb via exponential entity expansion attack.
If you are dealing with huge amount of data, use Workers and Queues to process as
much as possible in background and return response fast to avoid HTTP Blocking.
Output
Force content-type for your response. If you return application/json, then your
content-type response is application/json.
Return the proper status code according to the operation completed. (e.g. 200 OK,
400 Bad Request, 401 Unauthorized, 405 Method Not Allowed, etc.).
CI & CD
Ensure that all components of your services are statically scanned by AV software
before pushing to production, including vendor libraries and other dependencies.
See also:
yosriady/api-development-tools - A collection of useful resources for building RESTful
HTTP+JSON APIs.
Contribution
Feel free to contribute by forking this repository, making some changes, and submitting pull
requests. For any questions drop us an email at [email protected].
URL
https://github.com/shieldfy/API-Security-Checklist