google/oss-fuzz/fuzzing-memory-unsafe-expert
Claude Code and agent skill by google/oss-fuzz
- vendor
Checking that the SKILL.md file is still in the repository.
Use this skill to fuzz open source C/C++ software projects.
Install
npx vskill@latest install google/oss-fuzz/fuzzing-memory-unsafe-expertSKILL.md
Fuzzing memory-unsafe expert
This skill provides the agent with the necessary knowledge and tools to fuzz open source software projects, particularly those that are part of the OSS-Fuzz program. The agent can use this skill to build fuzzers, run fuzzing campaigns, analyze results, and improve the fuzzing posture of projects.
The fuzzing abilities focused on here is libFuzzer-style harnesses, which are commonly used in OSS-Fuzz.
Threat modelling and attack surface
Before writing a single line of harness code, decide what you are trying to find and where an attacker's input actually enters the code. A harness is only as good as the entry point it targets: a technically-correct harness pointed at code no attacker can influence finds bugs no maintainer will fix. This step is what separates a valuable harness from a noisy one.
What a threat model answers
For the target project, answer these four questions explicitly and write the answers into the harness's rationale doc:
- What input is untrusted? The data an attacker can control — a file
downloaded and opened, bytes arriving on a socket, a message from another process, a document pasted into an editor. Trusted input (a config file the admin wrote, a compile-time constant, a path only the program itself constructs) is not an attacker's lever and is usually out of scope.
- Where does that input cross a trust boundary? The exact function(s)
where untrusted bytes first reach parsing/processing logic. This is the entry point your harness should call.
- What does the attacker control at that boundary? The whole buffer? Only
a length field, with the rest validated upstream? A filename but not its contents? This determines what your harness should mutate and what it should hold fixed.
- What would count as a real bug here? A memory-safety violation (ASan/
MSan/UBSan finding) on attacker-reachable input is almost always in scope. A crash that requires trusted/malformed developer input, or an assert()-guarded programmer-error precondition, usually is not — fuzzing it produces findings maintainers reject.
Identifying the attack surface
Concrete, common attack surfaces in C/C++ projects, and the entry points to target for each:
- File-format parsers / loaders (image, audio, video, fonts, archives,
documents). Entry point: the function that takes a buffer or file and decodes it — e.g. png_read_info, TIFFClientOpen, av_read_frame, archive_read_open_memory. Attacker controls the whole file. High-value, classic OSS-Fuzz target.
- Network / wire-protocol handlers (packet parsers, TLS records, HTTP,
DNS, RPC deserialisation). Entry point: the function fed raw bytes off the wire, e.g. SSL_read, parse_packet, deserialize_message. Attacker controls the byte stream; often you must also drive a state machine (see the reachability note below).
- Serialisation / IPC boundaries (protobuf/JSON/CBOR/ASN.1 decoders,
shared-memory messages, clipboard, environment when spawned by another privilege domain). Entry point: the decode direction — the untrusted side is bytes-in, not object-out.
- Text / query languages (SQL, regex, template engines, config-language
parsers, expression evaluators). Entry point: the compile/parse function that accepts an arbitrary string.
- Decompression and codecs (zlib, lz4, zstd, JPEG/HEIF bitstreams). Entry
point: the decompress/decode call on attacker-supplied compressed data — these are prime targets because a small input expands into large, structured work.
Deriving the harness from the threat model
The threat model dictates the harness shape:
- Target the untrusted-input direction only. Fuzz the decoder, not the
encoder; the reader, not the writer — unless the writer also consumes attacker-controlled data.
- Mutate exactly what the attacker controls; fix the rest. If the attacker
controls a document but not the parser's configuration, mutate the document bytes and hold the config constant (set it once in LLVMFuzzerInitialize). Fuzzing the config too invents a threat that does not exist and yields rejected findings.
- Enter at the real trust boundary, not below it. Calling a deep internal
helper directly may crash on inputs the public API would have rejected upstream — a false positive. Prefer the outermost function an attacker's data actually reaches. If you must call an internal function for coverage, first confirm the upstream validation it assumes, and reproduce that precondition in the harness.
- Honour the API contract to avoid false positives. If a function is
documented to require NUL-terminated input, a valid handle, or a pre-allocated output buffer, supply those — a crash from violating the contract is a harness bug, not a target bug (this is the "True Positives" characteristic below).
Reachability: entry point is not enough
An entry point that is untrusted-reachable in production may still be unreachable from your harness if getting to the interesting code requires state the harness never sets up — an open session, a completed handshake, a prior header packet, a registered codec. Two consequences:
- If the deep code needs prior state, build that state in the harness
(e.g. feed a valid header, complete the handshake) before feeding the mutated bytes — otherwise the fuzzer never gets past the front door and coverage stays shallow.
- Cross-check with the coverage data (see the OSS-Fuzz engineer skill): if a
file you believe is attacker-reachable sits dark in summary.json, decide whether it is seed-limited (a better corpus would reach it — write seeds) or harness-limited (no input reaches it as the harness stands — the harness itself must set up more state).
A worked example
Consider a library that loads a custom image format via int img_load(const uint8_t *buf, size_t len, img_opts *opts), where opts comes from the application, not the file:
- Untrusted input:
buf/len(the image file). Trusted:opts. - Trust boundary / entry point:
img_load— the outermost public function
an attacker's bytes reach.
- Attacker controls: the entire image buffer, not the options.
- Real bug: any ASan/UBSan finding decoding a crafted image.
The harness therefore fixes opts to a representative default once, and feeds the mutated bytes as buf/len:
Fuzzing opts instead, or calling an internal decode_scanline directly with raw bytes, would either invent a non-existent threat or trip asserts the public API prevents — both produce findings maintainers will not act on.
Fundamental Concepts
Fuzzing harness core function
A fuzzing harness is a function that takes a byte array as input and processes it in a way that can trigger bugs or vulnerabilities in the software being tested. The core function of a fuzzing harness typically looks like this:
Return 0 in all normal cases. Return -1 to tell libFuzzer to reject an input and not add it to the corpus (rarely needed). Never exit() on bad input — it aborts the whole run and breaks coverage tooling.
Extracting typed input with FuzzedDataProvider
Most non-trivial targets do not take a single flat byte buffer — they need an integer here, a length there, a string, several sub-buffers. Passing the raw data/size directly to such an API means the fuzzer almost never produces a well-formed call. FuzzedDataProvider splits the one input stream into typed values, so libFuzzer's mutations map onto the parameters the target actually expects. It is the standard tool for this in OSS-Fuzz (used by well over a hundred projects) and is shipped in the base image — no dependency to add:
Commonly used methods (see compiler-rt's FuzzedDataProvider.h for the full set):
| Method | Description | |
|---|---|---|
ConsumeIntegral<T>() | one integer of type T | |
ConsumeIntegralInRange<T>(min, max) | integer bounded to [min, max] — use this to pick sizes, indices, enum values | |
ConsumeBool() | one boolean | |
ConsumeEnum<E>() | a value of a scoped enum with kMaxValue | |
ConsumeFloatingPoint<T>() / ...InRange(min, max) | float/double | |
ConsumeRandomLengthString(max) | a std::string whose length the fuzzer controls (stops at an escaped \) | |
ConsumeBytes<T>(count) / ConsumeBytesAsString(count) | exactly count bytes | |
ConsumeRemainingBytes<T>() / ConsumeRemainingBytesAsString() | everything left | |
remaining_bytes() | how many bytes are left to consume |
Guidance:
- Consume in a fixed order and document it. The mapping from bytes to
parameters must be stable, or a saved crash will not reproduce.
- Consume the variable-length / "rest of the input" argument last with
ConsumeRemaining.... Consuming a fixed count first and the remainder last keeps the layout robust to mutation.
- Bound sizes and indices with `ConsumeIntegralInRange` rather than masking
a raw integer — it wastes fewer inputs and keeps allocations sane.
- Use FDP when the target needs structure; for a target that genuinely takes
one opaque buffer (a single parse(data, size)), pass data/size straight through — FDP would only add noise.
One-time setup with LLVMFuzzerInitialize
If the harness needs setup that must happen once before fuzzing (parsing argv, setting environment variables, initialising a library global), put it in the optional LLVMFuzzerInitialize hook, which libFuzzer calls once at startup — never do per-input work there:
Keep expensive but per-process-constant state (loaded config, a compiled schema, an allocated context reused across inputs) in a file-scope static/global initialised once — either here or lazily on the first LLVMFuzzerTestOneInput call — so it is not rebuilt on every iteration.
Sanitizers are the bug oracle
A C/C++ harness rarely detects a bug by itself — the sanitizer the project is built with is what turns silent memory corruption into a crash the fuzzer can catch. OSS-Fuzz builds each target under a sanitizer (default AddressSanitizer; also UndefinedBehaviorSanitizer and MemorySanitizer):
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 1 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinginfra/experimental/agent-skills/fuzzing-memory-unsafe-expert/SKILL.md
Popularity
- Repository stars
- 12,684
- Repository forks
- 2,913
- 7-day trend score
- 47
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/google/oss-fuzz/fuzzing-memory-unsafe-expert)