pentest-api
REST + GraphQL + WebSocket guvenlik testi methodology. OWASP API Security Top 10 (2023) odakli.
Triggers
- "API pentest"
- "OWASP API Top 10"
- "GraphQL introspection"
- "JWT swap denemesi"
- "OAuth flow test"
- "BOLA / BFLA"
- "mass assignment"
- "WebSocket guvenlik"
OWASP API Top 10 (2023)
| # |
Kategori |
Test Yaklasimi |
| API1 |
BOLA (Broken Object Level Auth) |
/users/123 -> /users/124 enum, yetkisiz veri erisimi |
| API2 |
Broken Authentication |
Token replay, JWT manipulation, brute force endpoint |
| API3 |
Broken Object Property Level Auth |
Mass assignment (admin: true), excessive exposure |
| API4 |
Unrestricted Resource Consumption |
Rate limit eksik, pagination size, file upload size |
| API5 |
BFLA (Broken Function Level Auth) |
/admin/* user role ile erisilir mi |
| API6 |
Unrestricted Business Flows |
Bizlogic exploit (pentest-bizlogic'e devret) |
| API7 |
SSRF |
URL parametre cloud metadata reach |
| API8 |
Security Misconfig |
Verbose error, CORS *, default endpoint |
| API9 |
Improper Inventory |
v1/v2 ayni endpoint farkli auth, shadow API |
| API10 |
Unsafe Consumption of 3rd Party API |
API anahtari exfil, response trust |
REST Test Methodology
1. Spec dokuman bul: /swagger.json, /openapi.yaml, /api-docs
2. Endpoint listele + auth gereksinimleri
3. BOLA: numeric ID enum (user_id, doc_id, order_id)
4. BFLA: rol degisikligi (cookie/header swap)
5. Rate limit: 100 istek/sn 60sn icinde
6. CORS: Origin: evil.com -> reflect?
7. Verbose error: malformed body, sql-like input
GraphQL Test
# Introspection check (QUIET)
curl -X POST https://<hedef>/graphql -H 'Content-Type: application/json' -d '{"query":"{__schema{types{name fields{name}}}}"}'
# Common queries
- Field suggestion (typo) -> auto-suggest reveal
- Batching: tek POST'ta 1000 query (DoS hazirlik testi)
- Alias overloading
- Deep nesting: { user { friend { friend { ... } } } } depth 10+
JWT Analiz
| Test |
Yaklasim |
| alg: none |
Header'i {"alg":"none","typ":"JWT"} yap, imzayi sil |
| alg confusion |
RS256 -> HS256, public key'i secret olarak kullan |
| kid injection |
kid: ../../../dev/null (SQL kid varsa SQLi) |
| exp ignore |
exp gecmis, server yine de kabul ediyor mu |
| Weak secret |
hashcat ile JWT secret crack (offline) |
# QUIET — decode only (hicbir hedefe istek yok)
echo "<token>" | python3 -c "import sys,jwt; print(jwt.decode(sys.stdin.read().strip(), options={'verify_signature': False}))"
OAuth Flow Test
- redirect_uri tampering: evil.com'a token gonderme
- state parameter eksik -> CSRF
- response_type=token (implicit) hala destekleniyor mu
- PKCE eksik (mobile/SPA icin zorunlu)
- scope creep: minimal scope iste, max scope geldi mi
- Refresh token rotation eksik
Mass Assignment Test
POST /api/users
Content-Type: application/json
{
"name": "test",
"email": "test@example.com",
"isAdmin": true, # mass assignment
"subscription": "premium" # mass assignment
}
Response'da isAdmin: true donerse zafiyet var.
WebSocket
- Origin header validation eksik mi (CSRF-like)
- Authentication tek handshake'te mi (mid-session re-auth?)
- Message size limit
- Binary message + WS Frame manipulation
Output Sablonu
## API Analiz — <baseURL>
### Bulgu
- [HIGH] BOLA in GET /api/orders/{id} — user A, user B siparisini gorebiliyor
- [MEDIUM] GraphQL introspection production'da acik
- [LOW] CORS Origin reflection (sadece null origin)
### Test Edilmemis Alanlar
- BFLA admin endpoint (admin token yok)
- WebSocket /ws — handshake test edilmedi
- Rate limit thresholdu (musteri test penceresi disinda)
Out-of-Scope
- Live brute force (pentest-credentials)
- DDoS via rate limit absent
- Token replay attack saglayan automated tool
1---2name: pentest-api3description: API security testing — REST/GraphQL/WebSocket, OWASP API Top 10, JWT/OAuth analiz, mass assignment, broken object-level authorization advisory. Triggers on API pentest, OWASP API, REST security, GraphQL test, WebSocket, JWT analysis, OAuth flow, BOLA, BFLA, mass assignment.4license: MIT5compatibility: Works with Claude Code6allowed-tools: Read Write Edit Bash Grep7metadata:8 source: https://skillmd.com/skills/aibot88/pentest-api9 author: badi10 badi-version: ">=1.24.0"11 category: pentest12 scope: advisory13 inspired-by: 0xSteph/pentest-ai-agents api-security14---1516# pentest-api1718REST + GraphQL + WebSocket guvenlik testi methodology. OWASP API Security Top 10 (2023) odakli.1920## Triggers2122- "API pentest"23- "OWASP API Top 10"24- "GraphQL introspection"25- "JWT swap denemesi"26- "OAuth flow test"27- "BOLA / BFLA"28- "mass assignment"29- "WebSocket guvenlik"3031## OWASP API Top 10 (2023)3233| # | Kategori | Test Yaklasimi |34|---|----------|---------------|35| API1 | BOLA (Broken Object Level Auth) | /users/123 -> /users/124 enum, yetkisiz veri erisimi |36| API2 | Broken Authentication | Token replay, JWT manipulation, brute force endpoint |37| API3 | Broken Object Property Level Auth | Mass assignment (admin: true), excessive exposure |38| API4 | Unrestricted Resource Consumption | Rate limit eksik, pagination size, file upload size |39| API5 | BFLA (Broken Function Level Auth) | /admin/* user role ile erisilir mi |40| API6 | Unrestricted Business Flows | Bizlogic exploit (pentest-bizlogic'e devret) |41| API7 | SSRF | URL parametre cloud metadata reach |42| API8 | Security Misconfig | Verbose error, CORS *, default endpoint |43| API9 | Improper Inventory | v1/v2 ayni endpoint farkli auth, shadow API |44| API10 | Unsafe Consumption of 3rd Party API | API anahtari exfil, response trust |4546## REST Test Methodology4748```491. Spec dokuman bul: /swagger.json, /openapi.yaml, /api-docs502. Endpoint listele + auth gereksinimleri513. BOLA: numeric ID enum (user_id, doc_id, order_id)524. BFLA: rol degisikligi (cookie/header swap)535. Rate limit: 100 istek/sn 60sn icinde546. CORS: Origin: evil.com -> reflect?557. Verbose error: malformed body, sql-like input56```5758## GraphQL Test5960```bash61# Introspection check (QUIET)62curl -X POST https://<hedef>/graphql -H 'Content-Type: application/json' -d '{"query":"{__schema{types{name fields{name}}}}"}'6364# Common queries65- Field suggestion (typo) -> auto-suggest reveal66- Batching: tek POST'ta 1000 query (DoS hazirlik testi)67- Alias overloading68- Deep nesting: { user { friend { friend { ... } } } } depth 10+69```7071## JWT Analiz7273| Test | Yaklasim |74|------|----------|75| alg: none | Header'i `{"alg":"none","typ":"JWT"}` yap, imzayi sil |76| alg confusion | RS256 -> HS256, public key'i secret olarak kullan |77| kid injection | `kid: ../../../dev/null` (SQL kid varsa SQLi) |78| exp ignore | exp gecmis, server yine de kabul ediyor mu |79| Weak secret | hashcat ile JWT secret crack (offline) |8081```bash82# QUIET — decode only (hicbir hedefe istek yok)83echo "<token>" | python3 -c "import sys,jwt; print(jwt.decode(sys.stdin.read().strip(), options={'verify_signature': False}))"84```8586## OAuth Flow Test8788- redirect_uri tampering: evil.com'a token gonderme89- state parameter eksik -> CSRF90- response_type=token (implicit) hala destekleniyor mu91- PKCE eksik (mobile/SPA icin zorunlu)92- scope creep: minimal scope iste, max scope geldi mi93- Refresh token rotation eksik9495## Mass Assignment Test9697```http98POST /api/users99Content-Type: application/json100101{102 "name": "test",103 "email": "test@example.com",104 "isAdmin": true, # mass assignment105 "subscription": "premium" # mass assignment106}107```108109Response'da `isAdmin: true` donerse zafiyet var.110111## WebSocket112113- Origin header validation eksik mi (CSRF-like)114- Authentication tek handshake'te mi (mid-session re-auth?)115- Message size limit116- Binary message + WS Frame manipulation117118## Output Sablonu119120```markdown121## API Analiz — <baseURL>122123### Bulgu124- [HIGH] BOLA in GET /api/orders/{id} — user A, user B siparisini gorebiliyor125- [MEDIUM] GraphQL introspection production'da acik126- [LOW] CORS Origin reflection (sadece null origin)127128### Test Edilmemis Alanlar129- BFLA admin endpoint (admin token yok)130- WebSocket /ws — handshake test edilmedi131- Rate limit thresholdu (musteri test penceresi disinda)132```133134## Out-of-Scope135136- Live brute force (pentest-credentials)137- DDoS via rate limit absent138- Token replay attack saglayan automated tool