API Pentesting Notes
Modern applications are built on APIs, and APIs introduce their own class of vulnerabilities. This post covers the full API testing methodology from discovery through exploitation, with a focus on REST and GraphQL.
API Discovery & Enumeration
Before you can test, you need to find the API surface.
Documentation endpoints
|
Wordlists for fuzzing
|
JavaScript file mining
Most SPAs bundle API endpoints in JS:
|
Postman / API collection leaks
|
REST API Testing
BOLA / IDOR (Broken Object Level Authorization)
The most common and critical API vulnerability. The API doesn’t verify that the requester owns the requested object.
|
Change 1234 to another user’s ID. If it returns their orders, BOLA is confirmed.
Testing methodology:
- Create two accounts (A and B).
- Perform all actions as account A, note all object IDs.
- Replay every request with account B’s token.
- Any data returned from A’s objects = BOLA.
ID formats to try:
|
BFLA (Broken Function Level Authorization)
Testing whether regular users can call admin-only endpoints:
|
Also test HTTP method switching:
|
Mass Assignment
APIs that bind request body directly to database models often expose internal fields:
|
Try adding privileged fields:
|
Find candidate fields from GET responses — the field names used in responses are often the same ones accepted in POST/PUT.
API Versioning Issues
Older API versions often lack security controls applied to newer versions:
|
GraphQL Testing
Introspection
If introspection is enabled, you get the full schema:
|
Or enumerate types:
|
Tools: InQL (Burp extension), GraphQL Voyager, graphql-path-enum
Introspection disabled — field suggestions
GraphQL often returns “Did you mean X?” suggestions even when introspection is off:
|
Wordlist-based field enumeration exploiting this: Clairvoyance
|
IDOR via GraphQL
|
Change 1234 to another user’s ID.
Batching Attacks
GraphQL supports batching multiple operations in a single request:
|
Use this to bypass rate limiting on brute-force attacks (OTP, password reset tokens).
Mutation Privilege Escalation
|
Nested Query DoS (Query Depth)
|
Each level multiplies the database queries. Without depth limiting, this causes DoS.
Authentication Testing
JWT in API context
|
API key in unexpected locations
|
Check JavaScript source, mobile apps, and public GitHub repos for leaked keys.
OAuth token scope escalation
|
Even with read scope, admin endpoints might not verify scope granularly.
Rate Limiting Bypass
|
Common API Tools
|
API Checklist
- Discover all endpoints via JS mining, docs, and fuzzing
- Test BOLA on every object ID (swap between accounts)
- Test BFLA on admin/privileged endpoints with regular user tokens
- Try mass assignment on all POST/PUT/PATCH endpoints
- Check all older API versions (
/v1,/v2,/beta,/mobile) - Test GraphQL introspection, field enumeration, batching, depth
- Verify authentication on every endpoint (remove/change token)
- Test rate limiting on auth endpoints (login, OTP, password reset)
- Check for sensitive data in responses (passwords, tokens, PII)
- Test HTTP method switching on every endpoint
Discussion
Leave a comment · All fields required · No spam
No comments yet. Be the first.