API-Security-Checklist
Checklist of the most important security countermeasures when designing, testing, and releasing your API
Top Related Projects
OWASP API Security Project
The OWASP Cheat Sheet Series was created to provide a concise collection of high value information on specific application security topics.
Microsoft REST API Guidelines
GraphQL is a query language and execution engine tied to any backend service.
The OpenAPI Specification Repository
The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
Quick Overview
The API-Security-Checklist is a comprehensive guide for building secure APIs. It provides a collection of best practices and security considerations for developers and security professionals to follow when designing, implementing, and maintaining APIs. The checklist covers various aspects of API security, from authentication and authorization to data validation and error handling.
Pros
- Offers a concise and easy-to-follow checklist format
- Covers a wide range of API security topics
- Regularly updated with community contributions
- Available in multiple languages
Cons
- Lacks in-depth explanations for each security recommendation
- May not cover all specific use cases or industry-specific requirements
- Requires additional research to implement some of the suggested practices
- Does not provide code examples or implementation details
As this is not a code library, we'll skip the code examples and getting started instructions sections.
Competitor Comparisons
OWASP API Security Project
Pros of API-Security
- Comprehensive coverage of API security topics, including detailed explanations and best practices
- Regularly updated with contributions from a large community of security experts
- Provides a structured approach to API security with the OWASP Top 10 API Security Risks
Cons of API-Security
- Can be overwhelming for beginners due to its extensive content
- Requires more time to navigate and find specific information
- Less focused on quick, actionable items compared to API-Security-Checklist
Code Comparison
API-Security-Checklist provides concise, easy-to-implement guidelines:
- [ ] Don't use basic authentication. 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.
API-Security offers more detailed explanations and examples:
- API1:2019 Broken Object Level Authorization
- Description: APIs tend to expose endpoints that handle object identifiers, creating a wide attack surface Level Access Control issue.
- Example:
- Attacker substitutes their user ID with another user's ID in API requests
- API processes request without verifying the requester has permission to access the resource
While API-Security-Checklist provides a quick reference for developers, API-Security offers in-depth knowledge and context for a more comprehensive understanding of API security issues and best practices.
The OWASP Cheat Sheet Series was created to provide a concise collection of high value information on specific application security topics.
Pros of CheatSheetSeries
- More comprehensive coverage of security topics beyond API security
- Regularly updated with contributions from a large community of security experts
- Provides in-depth explanations and rationale for security practices
Cons of CheatSheetSeries
- Can be overwhelming due to the large amount of information
- May require more time to find specific API security recommendations
- Less focused on API-specific security concerns
Code Comparison
While both repositories primarily focus on security guidelines rather than code examples, CheatSheetSeries occasionally includes code snippets for illustration. For example:
CheatSheetSeries (Input Validation):
public boolean isValidAge(int age) {
return (age >= 0 && age <= 120);
}
API-Security-Checklist doesn't typically include code snippets, instead focusing on concise, actionable items:
- [ ] Don't use basic authentication. Use standard authentication instead (e.g., JWT, OAuth).
- [ ] Don't reinvent the wheel in authentication, token generation, password storage. Use the standards.
This comparison highlights the different approaches: CheatSheetSeries offers more detailed explanations with occasional code examples, while API-Security-Checklist provides a more focused, checklist-style format for API security considerations.
Microsoft REST API Guidelines
Pros of api-guidelines
- Comprehensive coverage of API design principles, not limited to security
- Detailed explanations and rationale for each guideline
- Backed by Microsoft's extensive experience in API development
Cons of api-guidelines
- Less focused on security-specific concerns
- More complex and time-consuming to implement fully
- May be overwhelming for smaller projects or teams
Code Comparison
API-Security-Checklist example (Authentication):
- [ ] 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.
api-guidelines example (Authentication):
Authorization: Bearer <token>
[Authorize]
public class SecureController : Controller
{
// Controller actions
}
The API-Security-Checklist provides concise, actionable security items, while api-guidelines offers more detailed implementation guidance across various API aspects.
GraphQL is a query language and execution engine tied to any backend service.
Pros of GraphQL Spec
- Comprehensive documentation of the GraphQL query language and type system
- Provides a clear standard for implementing GraphQL APIs
- Regularly updated with new features and improvements
Cons of GraphQL Spec
- Focuses solely on GraphQL, not covering general API security concerns
- More complex and technical, requiring deeper understanding of GraphQL concepts
- Less actionable for developers looking for quick security guidelines
Code Comparison
API-Security-Checklist example (security-focused):
- [ ] Don't use basic authentication. 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.
GraphQL Spec example (language specification):
type Query {
hero: Character
human(id: String!): Human
droid(id: String!): Droid
}
type Character {
name: String!
appearsIn: [Episode!]!
}
While API-Security-Checklist provides concise security recommendations, GraphQL Spec defines the structure and behavior of GraphQL queries and types. The former is more accessible for general API security, while the latter is essential for GraphQL-specific implementations.
The OpenAPI Specification Repository
Pros of OpenAPI-Specification
- Comprehensive and standardized approach to API description
- Widely adopted in the industry, with extensive tooling support
- Enables automatic code generation and documentation
Cons of OpenAPI-Specification
- More complex and requires a steeper learning curve
- Focuses on API structure rather than security-specific concerns
- May require additional effort to implement security best practices
Code Comparison
API-Security-Checklist example (security-focused checklist):
- [ ] Don't use basic authentication. 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.
OpenAPI-Specification example (API structure description):
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
paths:
/users:
get:
summary: Returns a list of users
responses:
'200':
description: Successful response
While API-Security-Checklist focuses on security best practices, OpenAPI-Specification provides a structured way to describe API endpoints, request/response formats, and authentication methods. The former is more targeted towards security concerns, while the latter offers a comprehensive approach to API documentation and design.
The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
Pros of Insomnia
- Full-featured API development and testing tool with a user-friendly GUI
- Supports a wide range of API protocols and authentication methods
- Offers collaborative features for team-based API development
Cons of Insomnia
- Focuses on API development and testing, not specifically on security
- Requires installation and setup, unlike a simple checklist
- May have a steeper learning curve for beginners
Code Comparison
API-Security-Checklist is a markdown file, not a code repository. However, Insomnia does have code for its functionality. Here's a small example of how you might use Insomnia's JavaScript API:
const insomnia = require('insomnia-node-api');
(async () => {
const response = await insomnia.send('GET', 'https://api.example.com');
console.log(response.data);
})();
Summary
API-Security-Checklist is a comprehensive security-focused checklist for API development, while Insomnia is a full-featured API development and testing tool. API-Security-Checklist provides a quick reference for security best practices, making it easy to implement across projects. Insomnia offers a more hands-on approach to API development with its interactive interface and testing capabilities. While Insomnia can be used to implement security practices, it doesn't inherently focus on security like API-Security-Checklist does. The choice between the two depends on whether you need a security reference or a complete API development environment.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ç¹ä¸ç | ç®ä¸ç | اÙعربÙØ© | AzÉrbaycan | বাà¦à¦²à¦¾ | Català | ÄeÅ¡tina | Deutsch | Îλληνικά | Español | ÙØ§Ø±Ø³Û | Français | हिà¤à¤¦à¥ | Indonesia | Italiano | æ¥æ¬èª | íêµì´ | àºàº²àºªàº²àº¥àº²àº§ | ÐакедонÑки | മലയാളഠ| Ðонгол | Nederlands | Polski | Português (Brasil) | Ð ÑÑÑкий | à¹à¸à¸¢ | Türkçe | УкÑаÑнÑÑка | Tiếng Viá»t
API Security Checklist
Checklist of the most important security countermeasures when designing, testing, and releasing your API.
Authentication
- Don't use
Basic Auth
. Use standard authentication instead (e.g., JWT). - 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.
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 header. Force the algorithm in the backend (
HS256
orRS256
). - Make token expiration (
TTL
,RTTL
) as short as possible. - Don't store sensitive data in the JWT payload, it can be decoded easily.
- Avoid storing too much data. JWT is usually shared in headers and they have a size limit.
Access
- Limit requests (Throttling) to avoid DDoS / brute-force attacks.
- Use HTTPS on server side with TLS 1.2+ and secure ciphers to avoid MITM (Man in the Middle Attack).
- Use
HSTS
header with SSL to avoid SSL Strip attacks. - Turn off directory listings.
- For private APIs, allow access only from safelisted IPs/hosts.
Authorization
OAuth
- Always validate
redirect_uri
server-side to allow only safelisted URLs. - Always try to exchange for code and not tokens (don't allow
response_type=token
). - Use
state
parameter with a random hash to prevent CSRF on the OAuth authorization process. - Define the default scope, and validate scope parameters for each application.
Input
- Use the proper HTTP method according to the operation:
GET (read)
,POST (create)
,PUT/PATCH (replace/update)
, andDELETE (to delete a record)
, and respond with405 Method Not 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/xml
,application/json
, etc.) and respond with406 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
, orAPI keys
) in the URL, but use standard Authorization header. - Use only server-side encryption.
- 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.
- 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 data, make sure entity parsing is not enabled to avoid
XXE
(XML external entity attack). - If you are parsing XML, YAML or any other language with anchors and refs, make sure entity expansion is not enabled to avoid
Billion Laughs/XML bomb
via 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.
- Use non-executable stacks when available.
Output
- 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 returnapplication/json
, then yourcontent-type
response isapplication/json
. - Don't return sensitive data like
credentials
,passwords
, orsecurity tokens
. - Return the proper status code according to the operation completed. (e.g.,
200 OK
,400 Bad Request
,401 Unauthorized
,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.
- Continuously run security tests (static/dynamic analysis) on your code.
- Check your dependencies (both software and OS) for known vulnerabilities.
- Design a rollback solution for deployments.
Monitoring
- Use centralized logins for all services and components.
- Use agents to monitor all traffic, errors, requests, and responses.
- Use alerts for SMS, Slack, Email, Telegram, Kibana, Cloudwatch, etc.
- Ensure that you aren't logging any sensitive data like credit cards, passwords, PINs, etc.
- Use an IDS and/or IPS system to monitor your API requests and instances.
See also:
- yosriady/api-development-tools - A collection of useful resources for building RESTful HTTP+JSON APIs.
Contribution
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
.
Top Related Projects
OWASP API Security Project
The OWASP Cheat Sheet Series was created to provide a concise collection of high value information on specific application security topics.
Microsoft REST API Guidelines
GraphQL is a query language and execution engine tied to any backend service.
The OpenAPI Specification Repository
The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot