API Scenario Checklist-Old
API Scenario Checklist-Old
Don't use Basic Auth. Use standard authentication instead (e.g. JWT, OAuth).
Don't reinvent the wheel in Authentication, token generation, password storage. Use the standards.
Use Max Retry and jail features in Login.
Use encryption on all sensitive data.
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).
Make token expiration (TTL, RTTL) as short as possible.
Don't store sensitive data in the JWT payload, it can be decoded easily. (jwt.io)
OAuth
Access
Input
Use the proper HTTP method according to the operation: GET (read), POST (create), PUT/PATCH (replace/update), and DELE
Allowed if the requested method isn't appropriate for the requested resource.
Validate content-type on request Accept header (Content Negotiation) to allow only your supported format (e.g. application
Acceptable response if not matched.
Validate content-type of posted data as you accept (e.g. application/x-www-form-urlencoded, multipart/form-data, applica
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
Use an API Gateway service to enable caching, Rate Limit policies (e.g. Quota, Spike Arrest, or Concurrent Rate Limit) and de
Processing
Check if all the endpoints are protected behind authentication to avoid broken authentication process.
User own resource ID should be avoided. Use /me/orders instead of /user/654321/orders.
Don't auto-increment IDs. Use UUID instead.
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 en
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 ret
Do not forget to turn the DEBUG mode OFF.
Output
CI & CD
CRLF Injection: Add %0d%0aTest in the request and if application is vulnerable to CRLF, Test word is reflected in the
response
e.g.: GET /Vapi/api5/getuser.php%0d%0aTest HTTP/1.1
Testing for Directory Listing: Modify endpoint by removing all the sub folder names and observe the response.
Checking for content type XML/JSON supports?: Convert body parameter to XML/JSON and observe is you are getting
response accordingly
Testing for dangerous methods: Change method type from GET to PUT/DELETE and observe if respective action is taking
place.
Change method tyeps and observe the response:if any request works for both GET and POST methods.
Vulnearbility Title
Observe response for every API call,and check if USer ID,any token
or any extra information is being passed.
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.
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.
Content Type Vaidation
Reject requests containing unexpected or missing content typeheaders with HTTP
response status 406 Unacceptable or 415Unsupported Media Type.
Reject the request ( Ideally with a 406 Not Acceptable response) if theAccept header does
not specifically contain one of the allowable types.
Ensure sending intended content type headers in your response matching your body
content e.g. application/json and notapplication/javascript.
For XML content types ensure appropriate XML parser hardening, see the
XXE cheat sheet
Processing
Check if all the endpoints are protected behind authentication to avoid broken
authentication process.
Don't auto-increment IDs. Use UUID instead.(Universally Unique Identifiers: Big random
numbers)
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.
Use a CDN for file uploads.Content Delivery Network (CDN)
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.
Management Endpoint
Avoid exposing management endpoints via Internet.
If management endpoints must be accessible via the Internet, makesure that users must
use a strong authentication mechanism, e.g.multi-factor.
Expose management endpoints via different HTTP ports or hosts preferably on a different
NIC and restricted subnet.
Restrict access to these endpoints by firewall rules or use of access control lists.
API Keys
Enforce API keys for every request to the protected endpoint.
Return 429 Too Many Requests HTTP response code if requests are coming in too quickly.
Revoke the API key if the client violates the usage agreement.
Do not rely exclusively on API keys to protect sensitive, critical or high-value resources.
API Output Checks
Send X-Content-Type-Options: nosniff header.
Send X-Frame-Options: deny header.
Send Content-Security-Policy: default-src 'none' header.
Remove fingerprinting headers - X-Powered-By, Server, X-AspNet-Version, etc.
Force content-type for your response. If you return application/json,then your content-
type response is application/json.
Don't return sensitive data like credentials, Passwords, or security tokens.
Return the proper status code according to the operationcompleted. (e.g. 200 OK, 400
Bad Request, 401 Unauthorized, 405Method Not Allowed, etc.).
No Rate limitting
3rd Party API Abuse
Request Splitting: Making additional requests to 3rd party API through the target API
SSRF: APIS that can resolve URLs can be tricked in to making requests in the cotext of the
other server.
Unhandeled input from 3rd party
It can result in to unexpected errors in to target application
Audit Logs
Write audit logs before and after security related events.
Consider logging token validation errors in order to detect attacks.
Take care of log injection attacks by sanitising log data beforehand
CI & CD
Audit your design and implementation with unit/integration tests coverage.
Use a code
Ensure thatreview process and
all components disregard
of your self-approval.
services are statically scanned by AV software before
pushing to production, including vendor libraries and other dependencies.
Design a rollback solution for deployments.