The Art of Fuzzing, Part 3: web applications, APIs and protocols
Overview
This is the third of five articles on fuzz testing. Part 1 and Part 2 concerned programs that could be compiled with instrumentation. This article considers network services, which can be observed only through their responses, and it relies on the discussion of test oracles in Part 1, Section 7.
- Sections 1 to 3 explain why service fuzzing is black-box testing, introduce a local laboratory server, and show how to establish a baseline response.
- Sections 4 and 5 apply ffuf to content discovery and to the fuzzing of parameter values.
- Section 6 covers recursive discovery and fuzzing through an intercepting proxy.
- Section 7 describes specification-based API fuzzing with Schemathesis and the testing of object-level authorisation.
- Sections 8 and 9 apply grammar-based fuzzing to a network protocol with boofuzz and set out the ethical and legal constraints on testing live services.
1. Introduction
In the taxonomy of Part 1, fuzzing a network service is usually blackbox fuzzing. The tester can send requests and observe responses, but cannot instrument the server, so no coverage feedback is available to guide the search. Two consequences follow. First, the generation of inputs must compensate for the missing feedback, either through domain knowledge encoded in wordlists or through a model of the input format, such as an API schema or a protocol grammar. Second, the oracle must be constructed entirely from observable behaviour: status codes, response sizes, response content, timing and the continued availability of the service.
Most practical oracles for services are differential in a loose sense. The tester first establishes what a normal, uninteresting response looks like and then treats any response that departs from it as a candidate finding requiring manual examination. The quality of this baseline largely determines the quality of the results, as the following sections show.
2. The laboratory server
To allow every result to be checked against ground truth, this article uses the small HTTP server in Figure 1, which runs locally and contains deliberately planted behaviours. It is started with python3 web_lab.py in a separate terminal and listens only on the loopback interface.
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from urllib.parse import urlsplit, parse_qs
import json
SCHEMA = {
"openapi": "3.0.3",
"info": {"title": "Fuzzing lab", "version": "1"},
"paths": {"/divide": {"get": {
"parameters": [{"name": "n", "in": "query", "required": True,
"schema": {"type": "integer"}}],
"responses": {"200": {"description": "result"},
"400": {"description": "bad input"}}
}}}
}
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
url = urlsplit(self.path)
status = 200
if url.path == "/openapi.json":
body = json.dumps(SCHEMA)
elif url.path == "/divide":
try:
body = str(100 / int(parse_qs(url.query)["n"][0]))
except (ValueError, KeyError):
status, body = 400, "invalid integer"
except ZeroDivisionError:
status, body = 500, "division by zero"
elif url.path == "/admin":
status, body = 403, "Admin access denied"
elif url.path == "/backup.zip":
body = "FAKE BACKUP CONTENT"
elif url.path == "/search" and "debug" in parse_qs(url.query):
body = "Debug output enabled"
elif self.headers.get("Host") == "admin.lab.test":
body = "Admin virtual host"
else:
body = "Not found"
self.send_response(status)
self.send_header("Content-Type", "application/json"
if url.path == "/openapi.json" else "text/plain")
self.end_headers()
self.wfile.write(body.encode())
def log_message(self, *args):
pass
ThreadingHTTPServer(("127.0.0.1", 8765), Handler).serve_forever()
web_lab.py: a local server with five planted behaviours.The server hides an administrative page, a backup file, a debugging parameter, a second virtual host served from the same address, and a division endpoint that fails on one particular value. It also reproduces a behaviour common in real deployments: every request for a missing resource receives the status code 200 OK together with an error message in the body.
3. Establishing a baseline
Before any fuzzing, the tester should characterise the server's response to requests that are known to be uninteresting:
curl -i 'http://127.0.0.1:8765/a-route-that-does-not-exist'
curl -s 'http://127.0.0.1:8765/a-route-that-does-not-exist' | wc -c
The response carries status 200 and the nine-byte body Not found. This pattern is known as a soft 404: the content reports that the resource is missing while the status code reports success. An oracle that treated every 200 response as a discovery would therefore report every entry in a wordlist. For this server the body length is a reliable discriminator, since every missing resource produces exactly nine bytes. On real servers the error page frequently embeds the requested path, a timestamp or a request identifier, so its length varies; the tester should request several different missing resources and determine which characteristics remain constant before choosing a filter.
4. Content discovery
Content discovery is the search for resources that exist but are not linked from the application: administrative interfaces, backup files, debugging endpoints and alternative virtual hosts. ffuf performs this search by substituting each entry of a wordlist for the keyword FUZZ, which may appear anywhere in the request. Three small wordlists suffice for the laboratory:
printf 'admin\nbackup.zip\nmissing\n' > paths.txt
printf 'debug\nmode\nlang\n' > params.txt
printf 'admin.lab.test\nunknown.lab.test\n' > hosts.txt
The following three commands vary the path, the name of a query parameter and the Host header respectively. In each case -mc all retains responses with any status code, -fs 9 removes responses matching the nine-byte baseline, and -rate 5 -t 1 limits the request rate:
ffuf -u 'http://127.0.0.1:8765/FUZZ' -w paths.txt -mc all -fs 9 -rate 5 -t 1
ffuf -u 'http://127.0.0.1:8765/search?FUZZ=1' -w params.txt -mc all -fs 9 -rate 5 -t 1
ffuf -u 'http://127.0.0.1:8765/' -H 'Host: FUZZ' -w hosts.txt -mc all -fs 9 -rate 5 -t 1
| Position fuzzed | Value found | Status | Body length |
|---|---|---|---|
| Path | admin | 403 | 19 |
| Path | backup.zip | 200 | 19 |
| Parameter name | debug | 200 | 20 |
| Host header | admin.lab.test | 200 | 18 |
All four planted resources were found and no false positives were reported. The 403 response for admin is a finding in its own right, since it shows that a protected resource exists; this is why the status filter is relaxed with -mc all. The virtual-host result is obtained without any change to name resolution, because the connection is still made to the loopback address and only the Host header differs.
ffuf can also estimate the baseline automatically with the option -ac, which sends a set of calibration requests before the scan. This is convenient, but its output should be verified. In the tests reported here, ffuf 2.1.0-dev with -ac displayed its own random calibration string, adminHIFEiKFh, in place of the matching word admin, although the status and length were correct. Every candidate finding should therefore be replayed manually, for example with curl, before it is recorded.
For real targets, the effectiveness of content discovery depends largely on the wordlist. Public collections such as SecLists provide general-purpose lists, but lists derived from the target itself, from names appearing in its JavaScript, documentation and API paths, often perform better while sending far fewer requests.
5. Value fuzzing
Content discovery searches for resources; value fuzzing tests how an existing resource handles unusual input. The division endpoint accepts an integer parameter n. The following list contains values that developers commonly fail to anticipate, including zero, a negative number, scientific notation, a non-numeric string, an encoded null byte and an integer larger than 64 bits:
printf '1\n0\n-1\n1e3\nabc\n%%00\n99999999999999999999\n' > values.txt
ffuf -u 'http://127.0.0.1:8765/divide?n=FUZZ' -w values.txt -mc all -rate 5 -t 1
1 [Status: 200, Size: 5, ...]
0 [Status: 500, Size: 16, ...]
-1 [Status: 200, Size: 6, ...]
1e3 [Status: 400, Size: 15, ...]
abc [Status: 400, Size: 15, ...]
%00 [Status: 400, Size: 15, ...]
99999999999999999999 [Status: 200, Size: 5, ...]
The appropriate oracle here is that invalid input should produce a client error (status 400) and never a server error (status 500). Six of the seven values satisfy it. The value 0 produces a 500, revealing an unhandled division by zero. On a longer list, the option -mc 500-599 restricts the output to server errors.
The same method generalises to the main classes of injection vulnerability by substituting a value list appropriate to each class: quotation marks and comment sequences for SQL injection, traversal sequences such as ../ and their encodings for path traversal, and template expressions such as {{7*7}} for server-side template injection. Candidate findings are identified by changes in status, length, content or response time, and each must then be confirmed manually. A server error is evidence of unexpected behaviour; whether it constitutes a vulnerability depends on what the tester can demonstrate about its consequences.
6. Recursive discovery and proxy-based fuzzing
Where discovered directories contain further content, recursive tools are more efficient. feroxbuster repeats the discovery process inside each directory it finds. Since recursion multiplies the number of requests, depth, rate and duration should be bounded explicitly:
feroxbuster -u 'http://127.0.0.1:8765/' -w paths.txt --depth 2 \
--rate-limit 5 --scan-limit 1 --time-limit 30s
Recursion is enabled by default in feroxbuster; its -r option enables the following of redirects and should not be confused with recursion. gobuster offers a simpler, non-recursive alternative, with separate modes for directories, DNS names and virtual hosts.
Some requests cannot easily be reproduced by a command-line tool, for example when they depend on an authenticated session, a cross-site request forgery token that changes with every request, or an unusual encoding. In these cases the fuzzers integrated into intercepting proxies, such as Burp Suite's Intruder and ZAP's Fuzzer, are more convenient. The tester captures a valid request, marks a single position to vary, supplies a list of values and compares the responses. Varying one position at a time keeps each difference in behaviour attributable to a single cause.
7. Specification-based API fuzzing
Many web APIs publish a machine-readable description of their operations in the OpenAPI format, listing each endpoint, its parameters and their types. Such a description plays the role of the grammar in grammar-based fuzzing: it allows a tool to generate requests that are structurally valid and therefore reach the application's logic. Schemathesis generates and executes such requests and checks the responses against a set of built-in properties. The laboratory server publishes a description at /openapi.json:
python3.11 -m venv .api-venv
.api-venv/bin/pip install 'schemathesis==4.34.2'
.api-venv/bin/schemathesis run 'http://127.0.0.1:8765/openapi.json' \
--url 'http://127.0.0.1:8765' \
--checks not_a_server_error --phases fuzzing \
--max-examples 20 --rate-limit 5/s
❌ ST101 Server error: 1
curl -X GET 'http://127.0.0.1:8765/divide?n=0'
From the declaration that n is an integer, Schemathesis generated integer values, found that zero causes a server error, and reported a curl command that reproduces the failure. No wordlist was required, because the specification supplied the structure of the input. Schemathesis 4 requires Python 3.11 or later; on older interpreters the package manager installs an earlier release with different options.
7.1 Object-level authorisation
A schema describes which requests are well formed. It cannot describe which principal is permitted to make them, and the most consequential API vulnerabilities lie in that gap. When an API returns, modifies or deletes an object identified by a client-supplied identifier without verifying that the requester is entitled to it, any user can access any other user's objects by changing the identifier. This defect is known as an insecure direct object reference or, in the OWASP API Security Top 10, as broken object-level authorisation, which has been the first entry in both the 2019 and 2023 editions [4].
Authorisation defects are not detected by crash or status-code oracles, because the vulnerable request succeeds normally. They require an oracle defined in terms of ownership, which can be constructed as follows. Two test accounts are created, here called Alice and Bob, and each creates a private object whose identifier is recorded. The baseline is established by confirming that each account can access its own object. Every request made by Alice is then replayed with Bob's identifier, and with identifiers adjacent to it. Any successful access to an object that Alice does not own is a failure, and the check should extend to modifications and deletions, which may succeed even when the response body is empty.
Schemathesis can automate part of this procedure through its object-level authorisation check when two users are configured; a clean result still requires manual review of the application's sharing rules. For APIs in which one operation creates an identifier that a later operation consumes, RESTler infers these dependencies from the specification and fuzzes complete sequences of requests, which allows it to reach states that isolated requests cannot.
8. Protocol fuzzing
A network protocol defines the structure and order of the messages exchanged between two parties: which message is sent first, how fields are delimited, how lengths are encoded and which replies are valid. Purely random mutation of protocol messages fails for the reason identified in Part 1: the server rejects almost every input at the first structural check. Protocol fuzzing is therefore usually grammar-based. boofuzz, a maintained descendant of the Sulley framework [3], allows the tester to describe a message as a sequence of fixed and variable fields, and then mutates the variable fields while keeping the remainder of the message valid.
8.1 Experiment
The server in Figure 2 implements a one-line protocol. A client sends HELLO followed by a name and a newline, and the server replies OK. A defect has been planted: a name longer than 100 bytes terminates the entire server process.
import os
import socketserver
class Handler(socketserver.StreamRequestHandler):
def handle(self):
line = self.rfile.readline(1024)
if not line.startswith(b"HELLO "):
self.wfile.write(b"ERROR\n")
return
name = line[6:].rstrip(b"\n")
if len(name) > 100:
os._exit(1) # Deliberate bug: a long name kills the whole server.
self.wfile.write(b"OK\n")
class Server(socketserver.ThreadingTCPServer):
allow_reuse_address = True
with Server(("127.0.0.1", 9009), Handler) as server:
server.serve_forever()
protocol_lab.py: a line-based protocol with a planted defect.Figure 3 describes the message to boofuzz. The verb and the terminating newline are declared static, so that every generated message remains syntactically valid, and only the name is mutated.
from boofuzz import Session, Target, TCPSocketConnection, Request, Static, String
session = Session(
target=Target(connection=TCPSocketConnection("127.0.0.1", 9009)),
receive_data_after_fuzz=True,
web_port=None,
keep_web_open=False,
)
message = Request("hello", children=(
Static("verb", b"HELLO "),
String("name", "student"),
Static("end", b"\n"),
))
session.connect(message)
session.fuzz()
fuzz_protocol.py: a boofuzz model of the message.python3 -m venv .protocol-venv
.protocol-venv/bin/pip install 'boofuzz==0.4.2'
.protocol-venv/bin/python fuzz_protocol.py
The relevant portion of the log, abbreviated, was as follows:
Test Case: 17: hello:[hello.name:16]
Transmitted 187 bytes: 48 45 4c 4c 4f 20 25 c3 be ...
Received:
Check OK: No crash detected.
Test Case: 18: hello:[hello.name:17]
Cannot connect to target; retrying. Note: This likely indicates
a failure caused by the previous test case ...
8.2 Analysis
Test case 17 transmitted a 180-byte name, which caused the server to terminate. boofuzz received an empty reply and nevertheless recorded “No crash detected”. The failure became visible only at test case 18, when the fuzzer could no longer connect. The reason is that this configuration has no monitor: boofuzz observes only the network connection, and an empty reply is not in itself a failure. The fuzzer did generate the triggering input, but its oracle did not recognise the consequence at the time.
This is a direct instance of the principle established in Part 1: the effectiveness of a fuzzing campaign is bounded by its oracle. For a real target, boofuzz should be configured with a process monitor or a health check that runs after every test case, together with a method for restarting the target, so that failures are attributed to the correct input and the campaign can continue. In this experiment, the saved test case 17 is the reproducer.
For research on stateful protocols, AFLNet combines the greybox approach of Part 2 with protocol awareness. It uses coverage feedback from an instrumented server together with a model of the protocol's states, inferred from the server's response codes. It requires the tester to build the server and to make each test begin from a known state, and it is therefore best regarded as a research instrument rather than a general-purpose scanner.
9. Ethical and legal constraints
Unlike the targets of Parts 1 and 2, network services are frequently shared with other users, and fuzzing them without authorisation may be unlawful as well as harmful. The following constraints should be treated as requirements.
- Only systems that the tester owns, or has written permission to test, may be fuzzed. The rules of a capture-the-flag competition and the published scope of a bug bounty programme constitute such permission, within their stated limits.
- Any rate limit specified by the programme must be respected. In the absence of one, a conservative rate of a few requests per second is appropriate.
- Testing should use dedicated test accounts and data, and should stop once sufficient evidence of a defect has been collected.
- Tests that deliberately degrade availability, such as the server termination in Section 8, are acceptable only in the tester's own environment or where the scope explicitly permits denial-of-service testing.
10. Conclusion
This article applied blackbox fuzzing to services that can be observed only through their responses. Against a local laboratory server, ffuf found all four planted resources once the soft-404 baseline had been measured and filtered, and a short list of unusual values exposed the one input that produced a server error. Schemathesis found the same failure using only the API's schema, and the discussion of object-level authorisation showed why the most valuable API defects require an ownership-based oracle. Finally, boofuzz generated a message that terminated a protocol server, while its unmonitored configuration reported no failure for that input. The principal points are the following.
- Without coverage feedback, the baseline is the foundation of the oracle. The characteristics of an uninteresting response, most often its length, must be measured before fuzzing begins.
- Discovery and value fuzzing answer different questions. The first finds resources and the second tests how they handle input, so a thorough assessment requires both.
- Tool output must be verified independently. Automated calibration and grouping can mislabel results, as the ffuf example showed, so each candidate should be replayed manually.
- Specifications supply structure but not authorisation rules. Schema-driven tools generate valid requests efficiently, while access-control testing requires an explicit model of ownership.
- A blackbox fuzzer is only as reliable as its monitoring. Health checks after every test case, together with authorisation and rate limits, are necessary conditions for meaningful and responsible results.
Exercises
- HostTrick. An administrative page is accessible only with a particular forwarding header and host value. Fuzz header names and values together.
- PathProwler. A path-traversal filter contains a flaw. Fuzz the path with traversal variants and filter on response length.
- VRFYLeak. An SMTP server discloses information through the
VRFYcommand. Fuzz candidate usernames and classify the reply codes. - BahCoin. A login endpoint leaks one bit of information per request. The exercise applies value fuzzing with a boolean oracle at scale.
Next
Part 4 applies the same principles to applications built on large language models, in which the input is natural language, the program includes a model that selects its own tool calls, and the authorisation oracle of Section 7.1 becomes central. Part 4: applications built on language models.
References
- ffuf, project repository; feroxbuster, documentation; gobuster, project repository; SecLists.
- Schemathesis, documentation; Microsoft, RESTler.
- boofuzz, documentation; P. Godefroid, Fuzzing: hack, art, and science, Communications of the ACM 63(2), 2020.
- OWASP, API Security Top 10, 2019 and 2023 editions.
- AFLNet, project repository.
Recorded runs: ffuf 2.1.0-dev against the local laboratory server and boofuzz 0.4.2 in python:3.11-slim (28 November 2026); Schemathesis 4.34.2, feroxbuster 2.14.0 and gobuster 3.8.2 (26 November 2026).