API Fuzzer
Overview
Perform API fuzzing to discover crashes, unhandled exceptions, security vulnerabilities, and edge case failures by sending malformed, unexpected, and boundary-value inputs to API endpoints. Supports RESTler (stateful REST API fuzzing), Schemathesis (OpenAPI-driven property-based testing), custom fuzz harnesses with fast-check, and OWASP ZAP active scanning.
Prerequisites
- API specification available (OpenAPI/Swagger, GraphQL SDL, or Protobuf definitions)
- Target API running in a test environment (never fuzz production)
- Fuzzing tool installed (Schemathesis, RESTler, or custom harness with fast-check/Hypothesis)
- API authentication credentials for protected endpoints
- Error logging enabled on the target server to capture crashes and stack traces
Instructions
- Parse the API specification to identify all endpoints, methods, and input schemas:
- Read OpenAPI spec files using Glob (
**/openapi.yaml, **/swagger.json).
- Catalog each endpoint's parameters (path, query, header, body) and their types.
- Note validation constraints (min/max, pattern, enum, required fields).
- Configure the fuzzing strategy:
- Schema-based: Generate inputs that violate schema constraints (wrong types, missing fields, extra fields).
- Mutation-based: Start with valid requests and mutate individual fields (bit flips, boundary values, special characters).
- Dictionary-based: Use known problematic inputs (SQL injection, XSS payloads, format strings, null bytes).
- Define fuzz input categories for each parameter type:
- Strings: Empty, very long (10K+ chars), unicode, null bytes, format strings (
%s%n), path traversal (../../etc/passwd).
- Numbers: 0, -1, MAX_INT, MIN_INT, NaN, Infinity, floats where ints expected.
- Arrays: Empty, single element, thousands of elements, nested arrays, mixed types.
- Objects: Empty, missing required fields, extra unknown fields, deeply nested (100+ levels).
- Dates: Invalid formats, epoch zero, far future, negative timestamps.
- Execute the fuzzing campaign:
- Run Schemathesis:
schemathesis run http://localhost:3000/openapi.json --stateful=links.
- Or run RESTler:
restler-fuzzer fuzz --grammar_file grammar.py.
- Or write custom fuzz tests with fast-check/Hypothesis for targeted endpoints.
- Set a time budget (30-60 minutes for initial run).
- Analyze findings:
- 5xx responses: Unhandled server errors -- file as bugs.
- Crashes/hangs: Application process terminated or stopped responding.
- Resource exhaustion: Memory/CPU spike from malicious payloads.
- Information disclosure: Stack traces, internal paths, or credentials in error responses.
- For each finding, create a minimal reproducer (smallest input that triggers the issue).
- Write regression tests for confirmed bugs to prevent reintroduction.
Output
- Fuzz campaign report with discovered issues sorted by severity
- Minimal reproducer for each finding (curl command or test case)
- Categorized findings: crashes, unhandled errors, security issues, validation gaps
- Regression test file with one test per confirmed bug
- Coverage metrics showing which endpoints and parameters were fuzzed
Error Handling
| Error |
Cause |
Solution |
| Fuzzer cannot parse API spec |
Invalid or incomplete OpenAPI specification |
Validate the spec with swagger-cli validate; fix schema errors before fuzzing |
| All requests return 401 |
Authentication not configured in fuzzer |
Provide auth headers via --set-header "Authorization: Bearer TOKEN" or config file |
| Server crashes during fuzzing |
Unhandled exception or resource exhaustion |
Restart the server with a process manager; enable crash dump collection; add OOM killer threshold |
| Too many false positives (500 errors) |
Application returns 500 for expected validation errors |
Filter known error patterns; configure the fuzzer to ignore specific response bodies |
| Fuzzer generates unrealistic inputs |
Schema-based generation produces impossible combinations |
Add x-examples to the OpenAPI spec; use stateful fuzzing to maintain valid sequences |
Examples
Schemathesis OpenAPI fuzzing:
# Basic schema-based fuzzing
schemathesis run http://localhost:3000/api/openapi.json \ # 3000: 3 seconds in ms
--stateful=links \
--hypothesis-max-examples=500 \ # HTTP 500 Internal Server Error
--base-url=http://localhost:3000 \ # 3 seconds in ms
--header "Authorization: Bearer $TEST_TOKEN"
# With specific checks
schemathesis run http://localhost:3000/api/openapi.json \ # 3 seconds in ms
--checks all \
--validate-schema=true
fast-check property-based API test:
import fc from 'fast-check';
import request from 'supertest';
import { app } from '../src/app';
test('POST /api/users handles arbitrary input without crashing', async () => {
await fc.assert(
fc.asyncProperty(
fc.record({
name: fc.string(),
email: fc.string(),
age: fc.oneof(fc.integer(), fc.string(), fc.constant(null)),
}),
async (body) => {
const res = await request(app).post('/api/users').send(body);
expect(res.status).toBeLessThan(500); // No server errors # HTTP 500 Internal Server Error
}
),
{ numRuns: 200 } # HTTP 200 OK
);
});
Custom fuzz dictionary for injection testing:
[
"' OR '1'='1",
"<script>alert(1)</script>",
"${7*7}",
"{{7*7}}",
"../../../etc/passwd",
"\u0000",
"A".repeat(100000) # 100000 = configured value
]
Resources
Source: jeremylongshore/claude-code-plugins-plus-skills → skills/.curated/fuzzing-apis/SKILL.md
Also appears in: jeremylongshore/claude-code-plugins-plus-skills/plugins/testing/api-fuzzer/skills/fuzzing-apis/SKILL.md
1---
2name: fuzzing-apis
3description: "'Configure perform API fuzzing to discover edge cases, crashes, and security vulnerabilities. Use when performing specialized testing. Trigger with phrases like \"fuzz the API\", \"run fuzzing tests\", or \"discover edge cases\". '"
4allowed-tools: "Read, Write, Edit, Grep, Glob, Bash(test:fuzz-*)"
5category: testing-and-qa
6source_repo: jeremylongshore/claude-code-plugins-plus-skills
7source_path: "skills/.curated/fuzzing-apis/SKILL.md"
8source_url: https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/HEAD/skills/.curated/fuzzing-apis/SKILL.md
9metadata:
10 source: https://skillmd.com/skills/thedixitjain/fuzzing-apis
11---
12
13# API Fuzzer
14
15## Overview
16
17Perform API fuzzing to discover crashes, unhandled exceptions, security vulnerabilities, and edge case failures by sending malformed, unexpected, and boundary-value inputs to API endpoints. Supports RESTler (stateful REST API fuzzing), Schemathesis (OpenAPI-driven property-based testing), custom fuzz harnesses with fast-check, and OWASP ZAP active scanning.
18
19## Prerequisites
20
21- API specification available (OpenAPI/Swagger, GraphQL SDL, or Protobuf definitions)
22- Target API running in a test environment (never fuzz production)
23- Fuzzing tool installed (Schemathesis, RESTler, or custom harness with fast-check/Hypothesis)
24- API authentication credentials for protected endpoints
25- Error logging enabled on the target server to capture crashes and stack traces
26
27## Instructions
28
291. Parse the API specification to identify all endpoints, methods, and input schemas:
30 - Read OpenAPI spec files using Glob (`**/openapi.yaml`, `**/swagger.json`).
31 - Catalog each endpoint's parameters (path, query, header, body) and their types.
32 - Note validation constraints (min/max, pattern, enum, required fields).
332. Configure the fuzzing strategy:
34 - **Schema-based**: Generate inputs that violate schema constraints (wrong types, missing fields, extra fields).
35 - **Mutation-based**: Start with valid requests and mutate individual fields (bit flips, boundary values, special characters).
36 - **Dictionary-based**: Use known problematic inputs (SQL injection, XSS payloads, format strings, null bytes).
373. Define fuzz input categories for each parameter type:
38 - **Strings**: Empty, very long (10K+ chars), unicode, null bytes, format strings (`%s%n`), path traversal (`../../etc/passwd`).
39 - **Numbers**: 0, -1, MAX_INT, MIN_INT, NaN, Infinity, floats where ints expected.
40 - **Arrays**: Empty, single element, thousands of elements, nested arrays, mixed types.
41 - **Objects**: Empty, missing required fields, extra unknown fields, deeply nested (100+ levels).
42 - **Dates**: Invalid formats, epoch zero, far future, negative timestamps.
434. Execute the fuzzing campaign:
44 - Run Schemathesis: `schemathesis run http://localhost:3000/openapi.json --stateful=links`.
45 - Or run RESTler: `restler-fuzzer fuzz --grammar_file grammar.py`.
46 - Or write custom fuzz tests with fast-check/Hypothesis for targeted endpoints.
47 - Set a time budget (30-60 minutes for initial run).
485. Analyze findings:
49 - **5xx responses**: Unhandled server errors -- file as bugs.
50 - **Crashes/hangs**: Application process terminated or stopped responding.
51 - **Resource exhaustion**: Memory/CPU spike from malicious payloads.
52 - **Information disclosure**: Stack traces, internal paths, or credentials in error responses.
536. For each finding, create a minimal reproducer (smallest input that triggers the issue).
547. Write regression tests for confirmed bugs to prevent reintroduction.
55
56## Output
57
58- Fuzz campaign report with discovered issues sorted by severity
59- Minimal reproducer for each finding (curl command or test case)
60- Categorized findings: crashes, unhandled errors, security issues, validation gaps
61- Regression test file with one test per confirmed bug
62- Coverage metrics showing which endpoints and parameters were fuzzed
63
64## Error Handling
65
66| Error | Cause | Solution |
67|-------|-------|---------|
68| Fuzzer cannot parse API spec | Invalid or incomplete OpenAPI specification | Validate the spec with `swagger-cli validate`; fix schema errors before fuzzing |
69| All requests return 401 | Authentication not configured in fuzzer | Provide auth headers via `--set-header "Authorization: Bearer TOKEN"` or config file |
70| Server crashes during fuzzing | Unhandled exception or resource exhaustion | Restart the server with a process manager; enable crash dump collection; add OOM killer threshold |
71| Too many false positives (500 errors) | Application returns 500 for expected validation errors | Filter known error patterns; configure the fuzzer to ignore specific response bodies |
72| Fuzzer generates unrealistic inputs | Schema-based generation produces impossible combinations | Add `x-examples` to the OpenAPI spec; use stateful fuzzing to maintain valid sequences |
73
74## Examples
75
76**Schemathesis OpenAPI fuzzing:**
77
78```bash
79# Basic schema-based fuzzing
80schemathesis run http://localhost:3000/api/openapi.json \ # 3000: 3 seconds in ms
81 --stateful=links \
82 --hypothesis-max-examples=500 \ # HTTP 500 Internal Server Error
83 --base-url=http://localhost:3000 \ # 3 seconds in ms
84 --header "Authorization: Bearer $TEST_TOKEN"
85
86# With specific checks
87schemathesis run http://localhost:3000/api/openapi.json \ # 3 seconds in ms
88 --checks all \
89 --validate-schema=true
90```
91
92**fast-check property-based API test:**
93
94```typescript
95import fc from 'fast-check';
96import request from 'supertest';
97import { app } from '../src/app';
98
99test('POST /api/users handles arbitrary input without crashing', async () => {
100 await fc.assert(
101 fc.asyncProperty(
102 fc.record({
103 name: fc.string(),
104 email: fc.string(),
105 age: fc.oneof(fc.integer(), fc.string(), fc.constant(null)),
106 }),
107 async (body) => {
108 const res = await request(app).post('/api/users').send(body);
109 expect(res.status).toBeLessThan(500); // No server errors # HTTP 500 Internal Server Error
110 }
111 ),
112 { numRuns: 200 } # HTTP 200 OK
113 );
114});
115```
116
117**Custom fuzz dictionary for injection testing:**
118
119```json
120[
121 "' OR '1'='1",
122 "<script>alert(1)</script>",
123 "${7*7}",
124 "{{7*7}}",
125 "../../../etc/passwd",
126 "\u0000",
127 "A".repeat(100000) # 100000 = configured value
128]
129```
130
131## Resources
132
133- Schemathesis: https://schemathesis.readthedocs.io/
134- RESTler (Microsoft): https://github.com/microsoft/restler-fuzzer
135- fast-check (property-based testing): https://fast-check.dev/
136- Hypothesis (Python): https://hypothesis.readthedocs.io/
137- OWASP Fuzzing: https://owasp.org/www-community/Fuzzing
138
139---
140
141**Source:** [`jeremylongshore/claude-code-plugins-plus-skills`](https://github.com/jeremylongshore/claude-code-plugins-plus-skills) → `skills/.curated/fuzzing-apis/SKILL.md`
142
143**Also appears in:** `jeremylongshore/claude-code-plugins-plus-skills/plugins/testing/api-fuzzer/skills/fuzzing-apis/SKILL.md`