API Security (API)
Analyze REST and RPC APIs for security vulnerabilities aligned with the OWASP
API Security Top 10, including Broken Object-Level Authorization (BOLA), mass
assignment, missing rate limiting, broken function-level authorization, and
excessive data exposure. API-specific vulnerabilities arise from the unique
patterns of programmatic access, where client-side UI constraints do not apply.
Supported Flags
Read ../../shared/schemas/flags.md for the full flag specification. This skill
supports all cross-cutting flags. Key flags for this skill:
--scope determines which files to analyze (default: changed)
--depth standard reads code and checks API endpoint handlers
--depth deep traces data from request to database to response serialization
--severity filters output (API issues are often high or critical)
Framework Context
Key CWEs in scope:
- CWE-639: Authorization Bypass Through User-Controlled Key (BOLA)
- CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes
- CWE-770: Allocation of Resources Without Limits (rate limiting)
- CWE-862: Missing Authorization (function-level auth)
- CWE-200: Exposure of Sensitive Information (excessive data)
OWASP API Security Top 10 (2023) categories:
- API1:2023 Broken Object-Level Authorization
- API2:2023 Broken Authentication
- API3:2023 Broken Object Property-Level Authorization
- API4:2023 Unrestricted Resource Consumption
- API5:2023 Broken Function-Level Authorization
Detection Patterns
Read references/detection-patterns.md for the full catalog of code patterns,
search heuristics, language-specific examples, and false positive guidance.
Workflow
1. Determine Scope
Parse flags and resolve the file list per ../../shared/schemas/flags.md.
Filter to files likely to contain API logic:
- Route/endpoint definitions (
**/routes/**, **/api/**, **/endpoints/**)
- Controllers and handlers (
**/controllers/**, **/handlers/**, **/views/**)
- Serializers and DTOs (
**/serializers/**, **/dto/**, **/schemas/**)
- Middleware (
**/middleware/**, **/middlewares/**)
- Rate limiting configuration (
**/config/**, **/limiters/**)
2. Check for Available Scanners
Detect scanners per ../../shared/schemas/scanners.md:
semgrep -- primary scanner for API patterns
bandit -- Python API security issues
brakeman -- Rails API vulnerabilities
Record which scanners are available and which are missing.
3. Run Scanners (If Available)
If semgrep is available, run with rules targeting API security:
semgrep scan --config auto --json --quiet <target>
Filter results to rules matching BOLA, mass assignment, authorization, and
data exposure patterns. Normalize output to the findings schema.
4. Claude Code Analysis
Regardless of scanner availability, perform manual code analysis:
- BOLA audit: Find API endpoints that accept resource IDs and verify each
enforces ownership or authorization before returning/modifying data.
- Mass assignment: Find endpoints that accept request bodies and bind them
directly to models without explicit field allowlisting.
- Rate limiting: Check for rate limiting middleware on authentication
endpoints, data-intensive endpoints, and mutation endpoints.
- Function-level authorization: Verify admin/privileged endpoints have
role-based authorization, not just authentication.
- Excessive data exposure: Check API responses for fields that should not
be exposed (passwords, internal IDs, sensitive user data).
When --depth deep, additionally trace:
- Full request-to-response data flow including serialization
- Authorization middleware chains across all API routes
- Rate limiting configuration and bypass scenarios
5. Report Findings
Format output per ../../shared/schemas/findings.md using the API prefix
(e.g., API-001, API-002).
Include for each finding:
- Severity and confidence
- Exact file location with code snippet
- OWASP API Top 10 reference
- Concrete fix with diff when possible
- CWE references
What to Look For
These are the high-signal patterns specific to API security. Each maps
to a detection pattern in references/detection-patterns.md.
Broken Object-Level Authorization (BOLA) -- API endpoints accept a
resource ID from the client and return data without verifying the requesting
user owns or is authorized to access that resource.
Mass assignment -- Request body fields are bound directly to database
model attributes, allowing attackers to set fields they should not control
(role, price, isAdmin).
Missing rate limiting -- API endpoints lack rate limiting, allowing
brute-force attacks on authentication, enumeration, and resource exhaustion.
Broken function-level authorization -- Admin or privileged API endpoints
are accessible to regular users because they check authentication but not
authorization role/permissions.
Excessive data exposure -- API responses include sensitive fields
(password hashes, tokens, internal metadata) that the client does not need.
Missing input validation -- API endpoints accept unbounded inputs
(no max length, no type validation) enabling injection and resource abuse.
Scanner Integration
| Scanner |
Coverage |
Command |
| semgrep |
BOLA, mass assignment, missing auth |
semgrep scan --config auto --json --quiet <target> |
| bandit |
Python API security patterns |
bandit -r <target> -f json -q |
| brakeman |
Rails mass assignment, authorization |
brakeman -q -f json -o /dev/stdout |
Fallback (no scanner): Use Grep with patterns from references/detection-patterns.md
to find API route definitions, model binding, rate limiting config, and response
serialization. Report findings with confidence: medium.
Output Format
Use the findings schema from ../../shared/schemas/findings.md.
- ID prefix:
API (e.g., API-001)
- metadata.tool:
api
- metadata.framework:
api
- metadata.category:
API
- references.api_top10:
API1:2023, API3:2023, etc.
- references.cwe:
CWE-639, CWE-915, CWE-770
- references.stride:
I (Information Disclosure) or E (Elevation of Privilege)
Severity guidance for this category:
- critical: BOLA on sensitive data (financial, medical, PII), mass assignment on role/privilege fields
- high: BOLA on user-scoped data, missing auth on admin endpoints, mass assignment on price/status
- medium: Missing rate limiting on auth endpoints, excessive data exposure of non-critical fields
- low: Minor data over-exposure, rate limit too generous but present
1---2name: api3description: This skill should be used when the user asks to "check API security", "audit REST API", "find BOLA vulnerabilities", "check for mass assignment", "analyze API rate limiting", "detect excessive data exposure", or mentions "API security", "BOLA", "IDOR", "mass assignment", "rate limiting", "broken function-level authorization", "excessive data exposure", or "OWASP API Top 10" in a security context.4---56# API Security (API)78Analyze REST and RPC APIs for security vulnerabilities aligned with the OWASP9API Security Top 10, including Broken Object-Level Authorization (BOLA), mass10assignment, missing rate limiting, broken function-level authorization, and11excessive data exposure. API-specific vulnerabilities arise from the unique12patterns of programmatic access, where client-side UI constraints do not apply.1314## Supported Flags1516Read `../../shared/schemas/flags.md` for the full flag specification. This skill17supports all cross-cutting flags. Key flags for this skill:1819- `--scope` determines which files to analyze (default: `changed`)20- `--depth standard` reads code and checks API endpoint handlers21- `--depth deep` traces data from request to database to response serialization22- `--severity` filters output (API issues are often `high` or `critical`)2324## Framework Context2526Key CWEs in scope:27- CWE-639: Authorization Bypass Through User-Controlled Key (BOLA)28- CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes29- CWE-770: Allocation of Resources Without Limits (rate limiting)30- CWE-862: Missing Authorization (function-level auth)31- CWE-200: Exposure of Sensitive Information (excessive data)3233OWASP API Security Top 10 (2023) categories:34- API1:2023 Broken Object-Level Authorization35- API2:2023 Broken Authentication36- API3:2023 Broken Object Property-Level Authorization37- API4:2023 Unrestricted Resource Consumption38- API5:2023 Broken Function-Level Authorization3940## Detection Patterns4142Read `references/detection-patterns.md` for the full catalog of code patterns,43search heuristics, language-specific examples, and false positive guidance.4445## Workflow4647### 1. Determine Scope4849Parse flags and resolve the file list per `../../shared/schemas/flags.md`.50Filter to files likely to contain API logic:5152- Route/endpoint definitions (`**/routes/**`, `**/api/**`, `**/endpoints/**`)53- Controllers and handlers (`**/controllers/**`, `**/handlers/**`, `**/views/**`)54- Serializers and DTOs (`**/serializers/**`, `**/dto/**`, `**/schemas/**`)55- Middleware (`**/middleware/**`, `**/middlewares/**`)56- Rate limiting configuration (`**/config/**`, `**/limiters/**`)5758### 2. Check for Available Scanners5960Detect scanners per `../../shared/schemas/scanners.md`:61621. `semgrep` -- primary scanner for API patterns632. `bandit` -- Python API security issues643. `brakeman` -- Rails API vulnerabilities6566Record which scanners are available and which are missing.6768### 3. Run Scanners (If Available)6970If semgrep is available, run with rules targeting API security:71```72semgrep scan --config auto --json --quiet <target>73```74Filter results to rules matching BOLA, mass assignment, authorization, and75data exposure patterns. Normalize output to the findings schema.7677### 4. Claude Code Analysis7879Regardless of scanner availability, perform manual code analysis:80811. **BOLA audit**: Find API endpoints that accept resource IDs and verify each82 enforces ownership or authorization before returning/modifying data.832. **Mass assignment**: Find endpoints that accept request bodies and bind them84 directly to models without explicit field allowlisting.853. **Rate limiting**: Check for rate limiting middleware on authentication86 endpoints, data-intensive endpoints, and mutation endpoints.874. **Function-level authorization**: Verify admin/privileged endpoints have88 role-based authorization, not just authentication.895. **Excessive data exposure**: Check API responses for fields that should not90 be exposed (passwords, internal IDs, sensitive user data).9192When `--depth deep`, additionally trace:93- Full request-to-response data flow including serialization94- Authorization middleware chains across all API routes95- Rate limiting configuration and bypass scenarios9697### 5. Report Findings9899Format output per `../../shared/schemas/findings.md` using the `API` prefix100(e.g., `API-001`, `API-002`).101102Include for each finding:103- Severity and confidence104- Exact file location with code snippet105- OWASP API Top 10 reference106- Concrete fix with diff when possible107- CWE references108109## What to Look For110111These are the high-signal patterns specific to API security. Each maps112to a detection pattern in `references/detection-patterns.md`.1131141. **Broken Object-Level Authorization (BOLA)** -- API endpoints accept a115 resource ID from the client and return data without verifying the requesting116 user owns or is authorized to access that resource.1171182. **Mass assignment** -- Request body fields are bound directly to database119 model attributes, allowing attackers to set fields they should not control120 (role, price, isAdmin).1211223. **Missing rate limiting** -- API endpoints lack rate limiting, allowing123 brute-force attacks on authentication, enumeration, and resource exhaustion.1241254. **Broken function-level authorization** -- Admin or privileged API endpoints126 are accessible to regular users because they check authentication but not127 authorization role/permissions.1281295. **Excessive data exposure** -- API responses include sensitive fields130 (password hashes, tokens, internal metadata) that the client does not need.1311326. **Missing input validation** -- API endpoints accept unbounded inputs133 (no max length, no type validation) enabling injection and resource abuse.134135## Scanner Integration136137| Scanner | Coverage | Command |138|---------|----------|---------|139| semgrep | BOLA, mass assignment, missing auth | `semgrep scan --config auto --json --quiet <target>` |140| bandit | Python API security patterns | `bandit -r <target> -f json -q` |141| brakeman | Rails mass assignment, authorization | `brakeman -q -f json -o /dev/stdout` |142143**Fallback (no scanner)**: Use Grep with patterns from `references/detection-patterns.md`144to find API route definitions, model binding, rate limiting config, and response145serialization. Report findings with `confidence: medium`.146147## Output Format148149Use the findings schema from `../../shared/schemas/findings.md`.150151- **ID prefix**: `API` (e.g., `API-001`)152- **metadata.tool**: `api`153- **metadata.framework**: `api`154- **metadata.category**: `API`155- **references.api_top10**: `API1:2023`, `API3:2023`, etc.156- **references.cwe**: `CWE-639`, `CWE-915`, `CWE-770`157- **references.stride**: `I` (Information Disclosure) or `E` (Elevation of Privilege)158159Severity guidance for this category:160- **critical**: BOLA on sensitive data (financial, medical, PII), mass assignment on role/privilege fields161- **high**: BOLA on user-scoped data, missing auth on admin endpoints, mass assignment on price/status162- **medium**: Missing rate limiting on auth endpoints, excessive data exposure of non-critical fields163- **low**: Minor data over-exposure, rate limit too generous but present