Modern apps are mostly APIs: your mobile app, your React frontend and your partners all talk to them. That makes APIs the main target for attackers. This is the checklist we run on every API before it goes live, grouped by the most common real-world failures in the OWASP API Security Top 10.
1. Authorization on every object (the #1 risk)
The most common serious API flaw is Broken Object Level Authorization (BOLA): a user changes /api/invoices/1001 to /api/invoices/1002 and sees someone else's invoice.
- Check ownership or permission on every request, not just at login.
- Scope queries to the current user:
Invoice.objects.filter(owner=request.user), notInvoice.objects.all(). - Write tests that try to access other users' objects.
# Django REST Framework
class InvoiceViewSet(viewsets.ModelViewSet):
serializer_class = InvoiceSerializer
permission_classes = [IsAuthenticated]
def get_queryset(self):
return Invoice.objects.filter(organisation=self.request.user.organisation)
2. Strong authentication
- Use proven standards (OAuth 2.0 / OpenID Connect, or well-configured JWTs and sessions). Don't invent your own.
- Short-lived access tokens, with refresh tokens that can be revoked.
- Rate-limit and monitor login, OTP and password-reset endpoints specifically.
- Never put tokens or passwords in URLs, since they end up in logs.
3. Property-level authorization
Don't return or accept more fields than needed:
- Excessive data exposure: serializers that return the whole model, including internal fields. List fields explicitly.
- Mass assignment: a user sends
"is_admin": trueor"status": "approved"and the API saves it. Mark sensitive fields read-only.
4. Rate limiting and resource limits
- Throttle per user and per IP (DRF throttles, an API gateway or the ingress controller).
- Cap page sizes, upload sizes and request body sizes.
- Set timeouts on expensive operations, and move heavy work to background jobs.
5. Function-level authorization
Admin endpoints must check for admin rights, even if the admin UI hides the buttons. Attackers don't use your UI. They read your JavaScript bundle and call endpoints directly.
6. Protect sensitive business flows
Think about abuse, not just bugs: automated sign-ups, scalping limited stock, coupon brute-forcing, OTP flooding. Add CAPTCHAs, velocity checks or manual review where business impact is high.
7. Validate input and outbound requests
- Validate types, lengths and formats with schemas (DRF serializers, Pydantic).
- Use the ORM or parameterised queries. Never build SQL with string concatenation.
- If your API fetches user-supplied URLs, guard against SSRF by blocking internal IP ranges and cloud metadata addresses.
8. Secure configuration
- HTTPS everywhere, with HSTS.
- Strict CORS: list allowed origins explicitly, never
*with credentials. DEBUG = Falsein production, and generic error messages without stack traces.- Remove default accounts, sample endpoints and unused HTTP methods.
9. Know your inventory
Old API versions and forgotten staging endpoints are a common way in. Keep an up-to-date list (OpenAPI specs help), retire old versions on a schedule, and never point staging at production data.
10. Be careful with third-party APIs you consume
Treat data from partner APIs and webhooks as untrusted. Validate it, verify signatures, and set timeouts.
Plus: logging and monitoring
Log authentication events, permission failures and unusual volumes, and alert on spikes. You can't respond to an attack you can't see.
Want an expert review before launch? Our API development team can audit your endpoints against this checklist.