SKILL.md--- name: atheris type: fuzzer description: "Sets up and runs Atheris, the coverage-guided Python fuzzer built on libFuzzer. Covers TestOneInput harnesses, FuzzedDataProvider, instrumenting both pure Python and native C extensions, and running under AddressSanitizer. Use when fuzzing a Python package, hunting memory corruption in a Python C extension, or choosing between Atheris and Hypothesis for a Python target." --- # Atheris Atheris is a coverage-guided Python fuzzer built on libFuzzer. It enables fuzzing of both pure Python code and Python C extensions with integrated AddressSanitizer support for detecting memory corruption issues. ## When to Use | Fuzzer | Best For | Complexity | |--------|----------|------------| | Atheris | Python code and C extensions | Low-Medium | | Hypothesis | Property-based testing | Low | | python-afl | AFL-style fuzzing | Medium | **Choose Atheris when:** - Fuzzing pure Python code with coverage guidance - Testing Python C extensions for memory corruption - Integration with libFuzzer ecosystem is desired - AddressSanitizer support is needed ## Quick Start ```python import sys import atheris @atheris.instrument_func def TestOneInput(data: bytes): if len(data) == 4: if data[0] == 0x46: # "F" if data[1] == 0x55: # "U" if data[2] == 0x5A: # "Z" if data[3] == 0x5A: # "Z" raise RuntimeError("You caught me") def main(): atheris.Setup(sys.argv, TestOneInput) atheris.Fuzz() if __name__ == "__main__": main() ``` Run: ```bash uv run python fuzz.py ``` ## Installation Atheris supports 32-bit and 64-bit Linux, and macOS. We recommend fuzzing on Linux because it's simpler to manage and often faster. ### Prerequisites - Python 3.7 or later - Recent version of clang (preferably [latest release](https://github.com/llvm/llvm-project/releases)) - For Docker users: [Docker Desktop](https://www.docker.com/products/docker-desktop/) ### Linux/macOS ```bash uv init --bare # once, if the harness directory is not yet a uv project uv add atheris ``` ### Docker Environment (Recommended) For a fully operational Linux environment with all dependencies configured: ```dockerfile # https://hub.docker.com/_/python ARG PYTHON_VERSION=3.11 FROM python:$PYTHON_VERSION-slim-bookworm RUN python --version RUN apt update && apt install -y \ ca-certificates \ wget \ && rm -rf /var/lib/apt/lists/* # LLVM builds version 15-19 for Debian 12 (Bookworm) # https://apt.llvm.org/bookworm/dists/ ARG LLVM_VERSION=19 RUN echo "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" > /etc/apt/sources.list.d/llvm.list RUN echo "deb-src http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" >> /etc/apt/sources.list.d/llvm.list RUN wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key > /etc/apt/trusted.gpg.d/apt.llvm.org.asc RUN apt update && apt install -y \ build-essential \ clang-$LLVM_VERSION \ && rm -rf /var/lib/apt/lists/* E