Skip to content

Commit de18461

Browse files
authored
Create README.md
1 parent b08b76f commit de18461

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[繁中版](./README-tw.md) | [簡中版](./README-zh.md) | [Português (Brasil)](./README-pt_BR.md) | [Français](./README-fr.md) | [한국어](./README-ko.md) | [Nederlands](./README-nl.md) | [Indonesia](./README-id.md) | [ไทย](./README-th.md) | [Русский](./README-ru.md) | [Українська](./README-uk.md) | [Español](./README-es.md) | [Italiano](./README-it.md) | [日本語](./README-ja.md) | [Deutsch](./README-de.md) | [Türkçe](./README-tr.md) | [Tiếng Việt](./README-vi.md) | [Монгол](./README-mn.md) | [हिंदी](./README-hi.md) | [العربية](./README-ar.md)
2+
3+
# API Security Checklist
4+
Checklist of the most important security countermeasures when designing, testing, and releasing your API.
5+
6+
7+
---
8+
9+
## Authentication
10+
- [ ] Don't use `Basic Auth` Use standard authentication (e.g. [JWT](https://jwt.io/), [OAuth](https://oauth.net/)).
11+
- [ ] Don't reinvent the wheel in `Authentication`, `token generation`, `password storage`. Use the standards.
12+
- [ ] Use `Max Retry` and jail features in Login.
13+
- [ ] Use encryption on all sensitive data.
14+
15+
### JWT (JSON Web Token)
16+
- [ ] Use a random complicated key (`JWT Secret`) to make brute forcing the token very hard.
17+
- [ ] Don't extract the algorithm from the payload. Force the algorithm in the backend (`HS256` or `RS256`).
18+
- [ ] Make token expiration (`TTL`, `RTTL`) as short as possible.
19+
- [ ] Don't store sensitive data in the JWT payload, it can be decoded [easily](https://jwt.io/#debugger-io).
20+
21+
### OAuth
22+
- [ ] Always validate `redirect_uri` server-side to allow only whitelisted URLs.
23+
- [ ] Always try to exchange for code and not tokens (don't allow `response_type=token`).
24+
- [ ] Use `state` parameter with a random hash to prevent CSRF on the OAuth authentication process.
25+
- [ ] Define the default scope, and validate scope parameters for each application.
26+
27+
## Access
28+
- [ ] Limit requests (Throttling) to avoid DDoS / brute-force attacks.
29+
- [ ] Use HTTPS on server side to avoid MITM (Man In The Middle Attack).
30+
- [ ] Use `HSTS` header with SSL to avoid SSL Strip attack.
31+
32+
## Input
33+
- [ ] 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.
34+
- [ ] 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.
35+
- [ ] Validate `content-type` of posted data as you accept (e.g. `application/x-www-form-urlencoded`, `multipart/form-data`, `application/json`, etc).
36+
- [ ] Validate User input to avoid common vulnerabilities (e.g. `XSS`, `SQL-Injection`, `Remote Code Execution`, etc).
37+
- [ ] Don't use any sensitive data (`credentials`, `Passwords`, `security tokens`, or `API keys`) in the URL, but use standard Authorization header.
38+
- [ ] Use an API Gateway service to enable caching, Rate Limit policies (e.g. `Quota`, `Spike Arrest`, `Concurrent Rate Limit`) and deploy APIs resources dynamically.
39+
40+
## Processing
41+
- [ ] Check if all the endpoints are protected behind authentication to avoid broken authentication process.
42+
- [ ] User own resource ID should be avoided. Use `/me/orders` instead of `/user/654321/orders`.
43+
- [ ] Don't auto-increment IDs. Use `UUID` instead.
44+
- [ ] If you are parsing XML files, make sure entity parsing is not enabled to avoid `XXE` (XML external entity attack).
45+
- [ ] If you are parsing XML files, make sure entity expansion is not enabled to avoid `Billion Laughs/XML bomb` via exponential entity expansion attack.
46+
- [ ] Use a CDN for file uploads.
47+
- [ ] 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.
48+
- [ ] Do not forget to turn the DEBUG mode OFF.
49+
50+
## Output
51+
- [ ] Send `X-Content-Type-Options: nosniff` header.
52+
- [ ] Send `X-Frame-Options: deny` header.
53+
- [ ] Send `Content-Security-Policy: default-src 'none'` header.
54+
- [ ] Remove fingerprinting headers - `X-Powered-By`, `Server`, `X-AspNet-Version` etc.
55+
- [ ] Force `content-type` for your response, if you return `application/json` then your response `content-type` is `application/json`.
56+
- [ ] Don't return sensitive data like `credentials`, `Passwords`, `security tokens`.
57+
- [ ] Return the proper status code according to the operation completed. (e.g. `200 OK`, `400 Bad Request`, `401 Unauthorized`, `405 Method Not Allowed`, etc).
58+
59+
## CI & CD
60+
- [ ] Audit your design and implementation with unit/integration tests coverage.
61+
- [ ] Use a code review process and disregard self-approval.
62+
- [ ] Ensure that all components of your services are statically scanned by AV software before push to production, including vendor libraries and other dependencies.
63+
- [ ] Design a rollback solution for deployments.
64+
65+
66+
---
67+
68+
## See also:
69+
- [yosriady/api-development-tools](https://github.com/yosriady/api-development-tools) - A collection of useful resources for building RESTful HTTP+JSON APIs.
70+
71+
72+
---
73+
74+
# Contribution
75+
Feel free to contribute by forking this repository, making some changes, and submitting pull requests. For any questions drop us an email at `team@shieldfy.io`.

0 commit comments

Comments
 (0)