繁中版 | 簡中版 | Português (Brasil) | Français | 한국어 | Nederlands | Indonesia | ไทย | Русский | Українська | Español | Italiano | 日本語 | Deutsch | Türkçe | Tiếng Việt | Монгол | हिंदी | العربية | Polski | Македонски | ລາວ | Ελληνικά
API Security Checklist
Checklist of the most important security countermeasures when designing, testing, and releasing your API.
- Don't use
Basic Auth. Use standard authentication (e.g. JWT, OAuth).
- Don't reinvent the wheel in
password storage. Use the standards.
Max Retryand jail features in Login.
- Use encryption on all sensitive data.
JWT (JSON Web Token)
- Use a random complicated key (
JWT Secret) to make brute forcing the token very hard.
- Don't extract the algorithm from the payload. Force the algorithm in the backend (
- Make token expiration (
RTTL) as short as possible.
- Don't store sensitive data in the JWT payload, it can be decoded easily.
- Always validate
redirect_uriserver-side to allow only whitelisted URLs.
- Always try to exchange for code and not tokens (don't allow
stateparameter with a random hash to prevent CSRF on the OAuth authentication process.
- Define the default scope, and validate scope parameters for each application.
- Limit requests (Throttling) to avoid DDoS / brute-force attacks.
- Use HTTPS on server side to avoid MITM (Man in the Middle Attack).
HSTSheader with SSL to avoid SSL Strip attack.
- Use the proper HTTP method according to the operation:
PUT/PATCH (replace/update), and
DELETE (to delete a record), and respond with
405 Method Not Allowedif the requested method isn't appropriate for the requested resource.
content-typeon request Accept header (Content Negotiation) to allow only your supported format (e.g.
application/json, etc.) and respond with
406 Not Acceptableresponse if not matched.
content-typeof posted data as you accept (e.g.
- Validate user input to avoid common vulnerabilities (e.g.
Remote Code Execution, etc.).
- Don't use any sensitive data (
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.
Spike Arrest, or
Concurrent Rate Limit) and deploy APIs resources dynamically.
- Check if all the endpoints are protected behind authentication to avoid broken authentication process.
- User own resource ID should be avoided. Use
- Don't auto-increment IDs. Use
- 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 bombvia exponential entity expansion attack.
- Use a CDN for file uploads.
- 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.
- Do not forget to turn the DEBUG mode OFF.
Content-Security-Policy: default-src 'none'header.
- Remove fingerprinting headers -
content-typefor your response, if you return
application/jsonthen your response
- Don't return sensitive data like
- Return the proper status code according to the operation completed. (e.g.
400 Bad Request,
405 Method Not Allowed, etc.).
CI & CD
- Audit your design and implementation with unit/integration tests coverage.
- Use a code review process and disregard self-approval.
- Ensure that all components of your services are statically scanned by AV software before pushing to production, including vendor libraries and other dependencies.
- Design a rollback solution for deployments.
- yosriady/api-development-tools - A collection of useful resources for building RESTful HTTP+JSON APIs.
Feel free to contribute by forking this repository, making some changes, and submitting pull requests. For any questions drop us an email at