fuzzing-python
FreeNo executable scriptsNot checkedCreating fuzz driver for Python libraries using LibFuzzer. This skill is useful when agent needs to work with creating fuzz drivers / fuzz targets for Python…
About this skill
Python Fuzzing Skill
Setting up fuzzing for a Python project
Fuzz testing for Python projects are Atheris. Atheris is a coverage-guided Python fuzzing engine. It supports fuzzing of Python code, but also native extensions written for CPython. Atheris is based off of libFuzzer. When fuzzing native code, Atheris can be used in combination with Address Sanitizer or Undefined Behavior Sanitizer to catch extra bugs.
You can install prebuilt versions of Atheris with pip:
pip3 install atheris
These wheels come with a built-in libFuzzer, which is fine for fuzzing Python code. If you plan to fuzz native extensions, you may need to build from source to ensure the libFuzzer version in Atheris matches your Clang version.
Using Atheris
Example
#!/usr/bin/python3
import atheris
with atheris.instrument_imports():
import some_library
import sys
def TestOneInput(data):
some_library.parse(data)
atheris.Setup(sys.argv, TestOneInput)
atheris.Fuzz()
When fuzzing Python, Atheris will report a failure if the Python code under test throws an uncaught exception.
Python coverage
Atheris collects Python coverage information by instrumenting bytecode. There are 3 options for adding this instrumentation to the bytecode:
You can instrument the libraries you import:
with atheris.instrument_imports(): import foo from bar import bazThis will cause instrumentation to be added to
fooandbar, as well as any libraries they import.Or, you can instrument individual functions:
@atheris.instrument_func def my_function(foo, bar): print("instrumented")Or finally, you can instrument everything:
atheris.instrument_all()Put this right before
atheris.Setup(). This will find every Python function currently loaded in the interpreter, and instrument it. This might take a while.
Atheris can additionally instrument regular expression checks, e.g. re.search.
To enable this feature, you will need to add:
atheris.enabled_hooks.add("RegEx")
To your script before your code calls re.compile.
Internally this will import the re module and instrument the necessary functions.
This is currently an experimental feature.
Similarly, Atheris can instrument str methods; currently only str.startswith
and str.endswith are supported. To enable this feature, add
atheris.enabled_hooks.add("str"). This is currently an experimental feature.
Why am I getting "No interesting inputs were found"?
You might see this error:
ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting.
You'll get this error if the first 2 calls to TestOneInput didn't produce any
coverage events. Even if you have instrumented some Python code,
this can happen if the instrumentation isn't reached in those first 2 calls.
(For example, because you have a nontrivial TestOneInput). You can resolve
this by adding an atheris.instrument_func decorator to TestOneInput,
using atheris.instrument_all(), or moving your TestOneInput function into an
instrumented module.
Visualizing Python code coverage
Examining which lines are executed is helpful for understanding the
effectiveness of your fuzzer. Atheris is compatible with
coverage.py: you can run your fuzzer using
the coverage.py module as you would for any other Python program. Here's an
example:
python3 -m coverage run your_fuzzer.py -atheris_runs=10000 # Times to run
python3 -m coverage html
(cd htmlcov && python3 -m http.server 8000)
Coverage reports are only generated when your fuzzer exits gracefully. This happens if:
- you specify
-atheris_runs=<number>, and that many runs have elapsed. - your fuzzer exits by Python exception.
- your fuzzer exits by
sys.exit().
No coverage report will be generated if your fuzzer exits due to a
crash in native code, or due to libFuzzer's -runs flag (use -atheris_runs).
If your fuzzer exits via other methods, such as SIGINT (Ctrl+C), Atheris will
attempt to generate a report but may be unable to (depending on your code).
For consistent reports, we recommend always using
-atheris_runs=<number>.
If you'd like to examine coverage when running with your corpus, you can do that with the following command:
python3 -m coverage run your_fuzzer.py corpus_dir/* -atheris_runs=$(( 1 + $(ls corpus_dir | wc -l) ))
This will cause Atheris to run on each file in <corpus-dir>, then exit.
Note: atheris use empty data set as the first input even if there is no empty file in <corpus_dir>.
Importantly, if you leave off the -atheris_runs=$(ls corpus_dir | wc -l), no
coverage report will be generated.
Using coverage.py will significantly slow down your fuzzer, so only use it for visualizing coverage; don't use it all the time.
Fuzzing Native Extensions
In order for fuzzing native extensions to be effective, your nativ
Install fuzzing-python in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the fuzzing-python skill do?
Creating fuzz driver for Python libraries using LibFuzzer. This skill is useful when agent needs to work with creating fuzz drivers / fuzz targets for Python project and libraries.
How do I install the fuzzing-python skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the fuzzing-python skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
by Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
by Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropic