API Security Roadmap

Step by step guide to becoming an Android developer.

Back to home

Legend

Propose
Alternatives
Options

1 Authentication

General:
Avoid 'Basic Authentication', use standard protocols (e.g. JWT, OAuth).
Don't reinvent the wheel in authentication mechanisms.
Use 'Max Retry' and jail features in Login.
Use encryption on all sensitive data.
JWT (JSON Web Token):
Use a good 'JWT Secret' to make brute force attacks difficult.
Don't extract the algorithm from the header; use the backend.
Make token expiration (TTL, RTTL) as short as possible.
Avoid storing sensitive data in the JWT payload.
Keep the payload small to reduce the size of the JWT token.
OAuth:
Always validate 'redirect_uri' on the server-side.
Avoid 'response_type=token' and try to exchange for code.
Use the 'state' parameter to prevent CSRF attacks.
Have a default scope, and validate the scope for each application.

2 Access Control

Limit requests (throttling) to avoid DDoS / Brute Force attacks.
Use HTTPS on the server side and secure ciphers.
Use the HSTS header with SSL to avoid SSL Strip attacks.
Turn off directory listings.
Private APIs should only be accessible from whitelisted IPs.

3 Input & Processing

Input Validation:
Use proper HTTP methods for the operation (GET, POST, PUT, DELETE).
Validate 'content-type' on the request header.
Validate user input to avoid common vulnerabilities (e.g., XSS, SQLi).
Use the standard Authorization header for sensitive data.
Use an API Gateway service to enable caching and rate limiting.
Processing & Output:
Use only server-side encryption.
Prefer using UUID over auto-increment IDs in resource URLs.
Disable entity parsing if you are parsing XML to avoid XXE attacks.
Use a CDN for file uploads.
Turn the debug mode off in production.
Send 'X-Content-Type-Options: nosniff' header.
Send 'X-Frame-Options: deny' header.
Send 'Content-Security-Policy: default-src 'none'' header.
Remove fingerprinting headers (e.g., X-Powered-By).
Force 'content-type' for your response.
Avoid returning sensitive data (credentials, security tokens, etc.).
Return proper response codes as per the operation.

4 CI & CD

Audit your design and implementation with unit/integration tests.
Use a code review process and disregard self-approval.
Continuously run security analysis on your code.
Check your dependencies for known vulnerabilities.
Design a rollback solution for deployments.

5 Monitoring

Use centralized logins for all services and components.
Use agents to monitor all requests, responses, and errors.
Use alerts for SMS, Slack, Email, Kibana, Cloudwatch, etc.
Ensure that you aren't logging any sensitive data.
Use an IDS and/or IPS system to monitor everything.