Security Checklist
This security checklist consists of security countermeasures when designing, testing, and releasing your API.
Authentication
Avoid creation of your own 'Authentication', 'Encryption', 'Password Generation' or 'Storage' mechanisms and use strong and robust standards already in place
Implement the use of
Max Retry
and jail features in on all login functionalityEnsure to encrypt all sensitive data
JSON Web Tokens (JWT)
Use a random and complicated
JWT Secret
to ensure the token cannot be brute-forcedDon't extract the algorithm from the header. Force the algorithm in the backend
HS256
orRS256
Ensure that the
TTL
andRTTL
which refer to 'Time To Live', are as short as possibleDon't store sensitive data in the JWT payload. These payloads can be decoded using resources like JWT Debugger
Open Authorization (OAuth)
Always validate
redirect_uri
server-side to allow only whitelisted URLsEnsure that communication is exchanged for code and not tokens and do not allow responses in tokens for example,
response_type=token
Use
state
as the parameter with a random hash to prevent CSRF on the authentication processDefine the default scope, and validate scope parameters for each application
Access
Throttle request by limiting them to avoid DDoS and brute-force attacks
Use HTTPS on server-side to avoid MiTM attacks
Use
HSTS
header with SSL to avoid SSL Strip attackFor private APIs, only allow access from whitelisted IPs/hosts
Input
Use the proper HTTP method according to the operation, for example, use
GET
, requests for 'reading' data,POST
requests for 'creation' of data,PUT
andPATCH
request to 'update or replace' the data andDELETE
, to 'remove' dataEnsure to respond with
405 Method Not Allowed
if a requested method isn't appropriate for the requested resourceValidate
content-type
on request Accept header for content negotiation to allow the supported format for exampleapplication/xml
,application/json
and respond with406 Not Acceptable
response if not matchedValidate
content-type
of posted data as you accept for exampleapplication/x-www-form-urlencoded
,multipart/form-data
,application/json
, etc.Validate user input to avoid common vulnerabilities in reference with the OWASP Top Ten such as SQL Injection, Cross-Site Scripting (XSS), Remote Code Execution amongst a list of others
Don't use any sensitive data such as credentials, security tokens or API keys in the URLs and only use an Authorization Header
Use an API Gateway service to enable caching, Rate Limit policies (e.g.
Quota
,Spike Arrest
, orConcurrent Rate Limit
) and deploy APIs resources dynamically.
Processing
Check if all the endpoints are protected behind authentication to avoid broken authentication process
Use of resource identifiers should be avoided. It is recommended to use
/web/purhcase
instead of/web/0098/purchase
Don't auto-increment identifiers and instead use
UUID
insteadIf you are parsing XML files, make sure entity parsing is not enabled to avoid XXE attacks
If you are parsing XML files, make sure entity expansion is not enabled to avoid XML bomb via exponential entity expansion attack
Use a CDN for file uploads
If you are dealing with a large amount of data, use Workers and Queues to process as much as possible in the background and return response quickly to avoid HTTP Blocking.
Ensure to set the
DEBUG
mode toOFF
Output
Ensure that the
X-Content-Type-Options: nosniff
header is setEnsure that the
X-Frame-Options: deny
header is setSend the
Content-Security-Policy: default-src 'none'
headerEnsure that the fingerprinting headers such as
X-Powered-By
,Server
,X-AspNet-Version
, etc are removed promptly before an application or service goes into productionForce the use of
content-type
for your response. If you returnapplication/json
, then yourcontent-type
response isapplication/json
Don't return sensitive data like 'Credentials' or 'Security Tokens'
Return the proper status code according to the operation completed for example
200 OK
,400 Bad Request
,401 Unauthorized
,405 Method Not Allowed
, etc.
Continuous Integration (CI) and Continuous Delivery (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
Last updated