| name | web-api-pentesting |
| description | How to perform comprehensive security testing on web APIs including REST, SOAP, GraphQL, and tRPC endpoints. Use this skill whenever the user needs to audit API security, test for authorization flaws, discover hidden endpoints, or assess API vulnerabilities. Trigger this skill for any API security assessment, penetration testing of web services, or when investigating potential API-based attacks like BOLA, XXE, or parameter tampering. |
Web API Pentesting Skill
A comprehensive methodology for security testing web APIs, covering REST, SOAP, GraphQL, and modern TypeScript stacks like tRPC.
Quick Start
- Identify API type (REST/JSON, SOAP/XML, GraphQL, tRPC)
- Map the attack surface (endpoints, parameters, authentication)
- Test for common vulnerabilities (authorization, injection, misconfigurations)
- Document findings with proof-of-concept requests
API Type Identification
REST APIs (JSON)
- Look for
/api/ paths, JSON responses, Swagger/OpenAPI docs
- Check for
swagger.json, openapi.yaml, or /api-docs endpoints
- Use Postman or curl to explore endpoints
SOAP/XML Web Services
- Check for
?wsdl paths (e.g., service.asmx?wsdl)
- Look for XML responses and SOAP envelopes
- Use SOAPUI or Burp Suite's WSDLer extension
GraphQL
- Look for
/graphql or /api/graphql endpoints
- Test introspection queries to map schema
- Check for query complexity limits
tRPC (TypeScript Runtime)
- Look for
/api/trpc/<router>.<procedure> patterns
- JSON body wrapped as
{"input": {...}}
- Common in modern TypeScript/Next.js stacks
Core Testing Methodology
1. Endpoint Discovery
Manual techniques:
- Check documentation (Swagger, Postman collections, README files)
- Review JavaScript bundles for API calls
- Monitor network traffic in browser DevTools
- Check for common patterns:
/api/v1/, /api/v2/, /api/admin/
Automated discovery:
kr scan https://target.com/api/ -w routes-large.kite -x 20
kr brute https://target.com/api/ -A=raft-large-words -x 20 -d=0
ffuf -u https://target.com/api/FUZZ -w /path/to/wordlist.txt
2. Authentication Testing
Test cases:
- Can you bypass authentication entirely?
- Does removing auth headers still work?
- Can you use another user's token/cookie?
- Test for session fixation and hijacking
Key checks:
- Try requests without authentication
- Test with expired/invalid tokens
- Attempt to use tokens across different user accounts
- Check for proper session invalidation on logout
3. Authorization Testing (AuthN ≠ AuthZ)
Critical distinction: Authentication proves who you are. Authorization determines what you can do.
Broken Object Level Authorization (BOLA) testing:
GET /api/users/123
GET /api/users/124
GET /api/users/1
GET /api/users/-1
GET /api/users/0
tRPC-specific authorization pitfalls:
protectedProcedure only checks authentication, NOT authorization
- Look for admin-only procedures accessible to regular users
- Test background job controls, feature flags, tenant-wide operations
Example tRPC exploitation:
curl -s -X POST 'https://target.com/api/trpc/backgroundMigrations.all' \
-H 'Content-Type: application/json' \
-b '<AUTH_COOKIES>' \
--data '{"input":{}}'
curl -s -X POST 'https://target.com/api/trpc/backgroundMigrations.retry' \
-H 'Content-Type: application/json' \
-b '<AUTH_COOKIES>' \
--data '{"input":{"name":"critical_migration"}}'
Impact assessment:
- Data corruption via non-idempotent operations
- DoS through worker/DB exhaustion
- Unauthorized data access or modification
4. Parameter Tampering
Test techniques:
- Add unexpected parameters
- Modify parameter values (IDs, flags, limits)
- Change data types (string to number, boolean to string)
- Test parameter pollution (duplicate parameters)
Examples:
GET /api/products?id=123
GET /api/products?id=123&admin=true
GET /api/products?id=123&price=0
GET /api/products?id=123&limit=10000
GET /api/products?id=123%26id=124
5. HTTP Method Testing
Test all methods on each endpoint:
curl -X GET https://target.com/api/users/123
curl -X POST https://target.com/api/users/123
curl -X PUT https://target.com/api/users/123
curl -X DELETE https://target.com/api/users/123
curl -X PATCH https://target.com/api/users/123
curl -X OPTIONS https://target.com/api/users/123
Look for:
- Unexpected method support
- Information disclosure via OPTIONS
- Method-based privilege escalation
6. Content-Type Manipulation
Test different content types:
curl -X POST https://target.com/api/data \
-H 'Content-Type: application/xml' \
--data '<data><id>123</id></data>'
curl -X POST https://target.com/api/data \
-H 'Content-Type: application/json' \
--data '{"id": 123}'
Vulnerabilities to find:
- XML External Entity (XXE) injection
- JSON parsing issues
- Content-Type bypass attacks
7. SOAP/XML Specific Testing
XXE Injection:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<test>
<data>
<![CDATA[<!ENTITY xxe SYSTEM "file:///etc/passwd">&xxe;]]>
</data>
</test>
</soap:Body>
</soap:Envelope>
Check for:
- DTD declarations (often restricted)
- CDATA tag payload insertion
- XML entity expansion attacks
8. CORS Misconfiguration Testing
Test cases:
curl -I -H 'Origin: https://evil.com' https://target.com/api/data
curl -I -H 'Origin: https://attacker.com' https://target.com/api/data
Vulnerabilities:
Access-Control-Allow-Origin: * with credentials
- Reflected origin without validation
- Missing CORS headers on sensitive endpoints
9. Version Testing
Test multiple API versions:
GET /api/v1/users
GET /api/v2/users
GET /api/v3/users
GET /api/v1/admin/users
Why it matters:
- Older versions often have known vulnerabilities
- Security controls may not be backported
- Deprecated endpoints may be forgotten
Tool Recommendations
Endpoint Discovery
- kiterunner: API endpoint discovery and brute forcing
- ffuf: Fast web fuzzer for path discovery
- Burp Suite: Professional web proxy with API testing features
API Auditing
- sj (BishopFox): Audit exposed Swagger/OpenAPI files
- Cherrybomb: OAS-based API security auditing (Rust)
- Postman: Manual API testing and collection management
Specialized Tools
- SOAPUI: SOAP API testing
- WSDLer: Burp extension for WSDL parsing
- Logger++: Burp extension with API vulnerability filters
Common Vulnerability Patterns
OWASP API Security Top 10
- Broken Object Level Authorization (BOLA) - Most common
- Broken Authentication - Session/token issues
- Broken Object Property Level Authorization - Mass assignment
- Unrestricted Resource Consumption - Rate limiting bypass
- Broken Function Level Authorization - Admin functions accessible
- Unrestricted Access to Sensitive Business Flows - Business logic abuse
- Server Side Request Forgery (SSRF) - Internal network access
- Security Misconfiguration - Default configs, verbose errors
- Improper Inventory Management - Unknown endpoints
- Unsafe Consumption of APIs - Third-party API risks
Quick Reference Checklist
Practice Resources
- VAmPI: Deliberately vulnerable API for practice
- OWASP API Security Top 10: Essential reading
- API Security Checklist: Comprehensive security guide
- Logger++ Filters: Burp filters for API hunting
Reporting Findings
For each vulnerability, document:
- Endpoint: Full URL and HTTP method
- Vulnerability type: Specific classification
- Steps to reproduce: Exact requests needed
- Impact: What an attacker could do
- Remediation: How to fix it
- Proof of concept: Request/response examples
Example report entry:
Vulnerability: Broken Object Level Authorization
Endpoint: GET /api/users/{id}
Severity: High
Description: Users can access other users' data by modifying the ID parameter
Steps:
1. Authenticate as user A (ID: 123)
2. Request /api/users/123 (returns own data)
3. Request /api/users/124 (returns user B's data - unauthorized)
Impact: Full data exposure across all users
Remediation: Add authorization check to verify user owns requested resource
Next Steps
After initial testing:
- Prioritize findings by severity and exploitability
- Validate false positives with additional testing
- Document remediation guidance for developers
- Re-test after fixes are applied
- Consider automated scanning for ongoing monitoring