[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CHCMGRA46VJFFFEPF5A077":3,"skill-same:01M7CHCMGRA46VJFFFEPF5A077":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7CHCMGRA46VJFFFEPF5A077","atheris",null,"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.","bongkage\u002Ftrailofbits-skills","bongkage","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F101378796?v=4","01M7CH419QTJ16DNJ33P0WCWBE","01M7CH41A9NWK8D2JBRK9F0M2C",1,"CC-BY-SA-4.0","https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftesting-handbook-skills\u002Fskills\u002Fatheris\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: atheris\ntype: fuzzer\ndescription: \"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.\"\n---\n\n# Atheris\n\nAtheris 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.\n\n## When to Use\n\n| Fuzzer | Best For | Complexity |\n|--------|----------|------------|\n| Atheris | Python code and C extensions | Low-Medium |\n| Hypothesis | Property-based testing | Low |\n| python-afl | AFL-style fuzzing | Medium |\n\n**Choose Atheris when:**\n- Fuzzing pure Python code with coverage guidance\n- Testing Python C extensions for memory corruption\n- Integration with libFuzzer ecosystem is desired\n- AddressSanitizer support is needed\n\n## Quick Start\n\n```python\nimport sys\nimport atheris\n\n@atheris.instrument_func\ndef TestOneInput(data: bytes):\n    if len(data) == 4:\n        if data[0] == 0x46:  # \"F\"\n            if data[1] == 0x55:  # \"U\"\n                if data[2] == 0x5A:  # \"Z\"\n                    if data[3] == 0x5A:  # \"Z\"\n                        raise RuntimeError(\"You caught me\")\n\ndef main():\n    atheris.Setup(sys.argv, TestOneInput)\n    atheris.Fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\nRun:\n```bash\nuv run python fuzz.py\n```\n\n## Installation\n\nAtheris supports 32-bit and 64-bit Linux, and macOS. We recommend fuzzing on Linux because it's simpler to manage and often faster.\n\n### Prerequisites\n\n- Python 3.7 or later\n- Recent version of clang (preferably [latest release](https:\u002F\u002Fgithub.com\u002Fllvm\u002Fllvm-project\u002Freleases))\n- For Docker users: [Docker Desktop](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop\u002F)\n\n### Linux\u002FmacOS\n\n```bash\nuv init --bare   # once, if the harness directory is not yet a uv project\nuv add atheris\n```\n\n### Docker Environment (Recommended)\n\nFor a fully operational Linux environment with all dependencies configured:\n\n```dockerfile\n# https:\u002F\u002Fhub.docker.com\u002F_\u002Fpython\nARG PYTHON_VERSION=3.11\n\nFROM python:$PYTHON_VERSION-slim-bookworm\n\nRUN python --version\n\nRUN apt update && apt install -y \\\n    ca-certificates \\\n    wget \\\n    && rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\n# LLVM builds version 15-19 for Debian 12 (Bookworm)\n# https:\u002F\u002Fapt.llvm.org\u002Fbookworm\u002Fdists\u002F\nARG LLVM_VERSION=19\n\nRUN echo \"deb http:\u002F\u002Fapt.llvm.org\u002Fbookworm\u002F llvm-toolchain-bookworm-$LLVM_VERSION main\" > \u002Fetc\u002Fapt\u002Fsources.list.d\u002Fllvm.list\nRUN echo \"deb-src http:\u002F\u002Fapt.llvm.org\u002Fbookworm\u002F llvm-toolchain-bookworm-$LLVM_VERSION main\" >> \u002Fetc\u002Fapt\u002Fsources.list.d\u002Fllvm.list\nRUN wget -qO- https:\u002F\u002Fapt.llvm.org\u002Fllvm-snapshot.gpg.key > \u002Fetc\u002Fapt\u002Ftrusted.gpg.d\u002Fapt.llvm.org.asc\n\nRUN apt update && apt install -y \\\n    build-essential \\\n    clang-$LLVM_VERSION \\\n    && rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\nENV APP_DIR \"\u002Fapp\"\nRUN mkdir $APP_DIR\nWORKDIR $APP_DIR\n\nENV VIRTUAL_ENV \"\u002Fopt\u002Fvenv\"\nRUN python -m venv $VIRTUAL_ENV\nENV PATH \"$VIRTUAL_ENV\u002Fbin:$PATH\"\n\n# https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#step-1-compiling-your-extension\nENV CC=\"clang-$LLVM_VERSION\"\nENV CFLAGS \"-fsanitize=address,fuzzer-no-link\"\nENV CXX=\"clang++-$LLVM_VERSION\"\nENV CXXFLAGS \"-fsanitize=address,fuzzer-no-link\"\nENV LDSHARED=\"clang-$LLVM_VERSION -shared\"\nENV LDSHAREDXX=\"clang++-$LLVM_VERSION -shared\"\nENV ASAN_SYMBOLIZER_PATH=\"\u002Fusr\u002Fbin\u002Fllvm-symbolizer-$LLVM_VERSION\"\n\n# Allow Atheris to find fuzzer sanitizer shared libs\n# https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris#building-from-source\nRUN LIBFUZZER_LIB=$($CC -print-file-name=libclang_rt.fuzzer_no_main-$(uname -m).a) \\\n    python -m pip install --no-binary atheris atheris\n\n# https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#option-a-sanitizerlibfuzzer-preloads\nENV LD_PRELOAD \"$VIRTUAL_ENV\u002Flib\u002Fpython3.11\u002Fsite-packages\u002Fasan_with_fuzzer.so\"\n\n# 1. Skip memory allocation failures for now, they are common, and low impact (DoS)\n# 2. https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#leak-detection\nENV ASAN_OPTIONS \"allocator_may_return_null=1,detect_leaks=0\"\n\nCMD [\"\u002Fbin\u002Fbash\"]\n```\n\nBuild and run:\n```bash\ndocker build -t atheris .\ndocker run -it atheris\n```\n\n### Verification\n\n```bash\npython -c \"import atheris; print(atheris.__version__)\"\n```\n\n## Writing a Harness\n\n### Harness Structure for Pure Python\n\n```python\nimport sys\nimport atheris\n\n@atheris.instrument_func\ndef TestOneInput(data: bytes):\n    \"\"\"\n    Fuzzing entry point. Called with random byte sequences.\n\n    Args:\n        data: Random bytes generated by the fuzzer\n    \"\"\"\n    # Add input validation if needed\n    if len(data) \u003C 1:\n        return\n\n    # Call your target function\n    try:\n        your_target_function(data)\n    except ValueError:\n        # Expected exceptions should be caught\n        pass\n    # Let unexpected exceptions crash (that's what we're looking for!)\n\ndef main():\n    atheris.Setup(sys.argv, TestOneInput)\n    atheris.Fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Structured Input with FuzzedDataProvider\n\nA target taking several typed arguments wastes most of the fuzzer's inputs if the harness\nslices `data` by hand, because every mutation shifts the byte offsets of everything after it.\n`atheris.FuzzedDataProvider` splits one `bytes` input into typed values instead:\n\n```python\nfdp = atheris.FuzzedDataProvider(data)\nname = fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(0, 64))\nstrict = fdp.ConsumeBool()\n```\n\nSee [structured-input.md](structured-input.md) for the full method reference, the fixed-draw-\norder rule, and what each method returns once the buffer runs dry.\n\n### Harness Rules\n\n| Do | Don't |\n|----|-------|\n| Use `@atheris.instrument_func` for coverage | Forget to instrument target code |\n| Catch expected exceptions | Catch all exceptions indiscriminately |\n| Use `atheris.instrument_imports()` for libraries | Import modules after `atheris.Setup()` |\n| Keep harness deterministic | Use randomness or time-based behavior |\n\n> **See Also:** For detailed harness writing techniques, patterns for handling complex inputs,\n> and advanced strategies, see the **fuzz-harness-writing** technique skill.\n\n## Fuzzing Pure Python Code\n\nFor fuzzing broader parts of an application or library, use instrumentation functions:\n\n```python\nimport atheris\nwith atheris.instrument_imports():\n    import your_module\n    from another_module import target_function\n\ndef TestOneInput(data: bytes):\n    target_function(data)\n\natheris.Setup(sys.argv, TestOneInput)\natheris.Fuzz()\n```\n\n**Instrumentation Options:**\n- `atheris.instrument_func` - Decorator for single function instrumentation\n- `atheris.instrument_imports()` - Context manager for instrumenting all imported modules\n- `atheris.instrument_all()` - Instrument all Python code system-wide\n\n## Fuzzing Python C Extensions\n\nPython C extensions require compilation with specific flags for instrumentation and sanitizer support.\n\n### Environment Configuration\n\nIf using the provided Dockerfile, these are already configured. For local setup:\n\n```bash\nexport CC=\"clang\"\nexport CFLAGS=\"-fsanitize=address,fuzzer-no-link\"\nexport CXX=\"clang++\"\nexport CXXFLAGS=\"-fsanitize=address,fuzzer-no-link\"\nexport LDSHARED=\"clang -shared\"\n```\n\n### Example: Fuzzing cbor2\n\nInstall the extension from source:\n```bash\nCBOR2_BUILD_C_EXTENSION=1 uv add --no-binary-package cbor2 'cbor2==5.6.4'\n```\n\nThe `--no-binary-package` flag ensures the C extension is compiled locally with\ninstrumentation rather than pulled as a prebuilt wheel. Persist that choice with\n`no-binary-package = [\"cbor2\"]` under `[tool.uv]` in `pyproject.toml`, or a later\n`uv sync` can silently swap in an uninstrumented wheel.\n\nCreate `cbor2-fuzz.py`:\n```python\nimport sys\nimport atheris\n\n# _cbor2 ensures the C library is imported\nfrom _cbor2 import loads\n\ndef TestOneInput(data: bytes):\n    try:\n        loads(data)\n    except Exception:\n        # We're searching for memory corruption, not Python exceptions\n        pass\n\ndef main():\n    atheris.Setup(sys.argv, TestOneInput)\n    atheris.Fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\nRun:\n```bash\nuv run python cbor2-fuzz.py\n```\n\n> **Important:** When running locally (not in Docker), you must [set `LD_PRELOAD` manually](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#option-a-sanitizerlibfuzzer-preloads).\n\n## Corpus Management\n\n### Creating Initial Corpus\n\n```bash\nmkdir corpus\n# Add seed inputs\necho \"test data\" > corpus\u002Fseed1\necho '{\"key\": \"value\"}' > corpus\u002Fseed2\n```\n\nRun with corpus:\n```bash\nuv run python fuzz.py corpus\u002F\n```\n\n### Corpus Minimization\n\nAtheris inherits corpus minimization from libFuzzer:\n```bash\nuv run python fuzz.py -merge=1 new_corpus\u002F old_corpus\u002F\n```\n\n> **See Also:** For corpus creation strategies, dictionaries, and seed selection,\n> see the **fuzzing-corpus** technique skill.\n\n## Running Campaigns\n\n### Basic Run\n\n```bash\nuv run python fuzz.py\n```\n\n### With Corpus Directory\n\n```bash\nuv run python fuzz.py corpus\u002F\n```\n\n### Common Options\n\n```bash\n# Run for 10 minutes\nuv run python fuzz.py -max_total_time=600\n\n# Limit input size\nuv run python fuzz.py -max_len=1024\n\n# Run with multiple workers\nuv run python fuzz.py -workers=4 -jobs=4\n```\n\n### Interpreting Output\n\n| Output | Meaning |\n|--------|---------|\n| `NEW    cov: X` | Found new coverage, corpus expanded |\n| `pulse  cov: X` | Periodic status update |\n| `exec\u002Fs: X` | Executions per second (throughput) |\n| `corp: X\u002FYb` | Corpus size: X inputs, Y bytes total |\n| `ERROR: libFuzzer` | Crash detected |\n\n## Sanitizer Integration\n\n### AddressSanitizer (ASan)\n\nAddressSanitizer is automatically integrated when using the provided Docker environment or when compiling with appropriate flags.\n\nFor local setup:\n```bash\nexport CFLAGS=\"-fsanitize=address,fuzzer-no-link\"\nexport CXXFLAGS=\"-fsanitize=address,fuzzer-no-link\"\n```\n\nConfigure ASan behavior:\n```bash\nexport ASAN_OPTIONS=\"allocator_may_return_null=1,detect_leaks=0\"\n```\n\n### LD_PRELOAD Configuration\n\nFor native extension fuzzing:\n```bash\nexport LD_PRELOAD=\"$(python -c 'import atheris; import os; print(os.path.join(os.path.dirname(atheris.__file__), \"asan_with_fuzzer.so\"))')\"\n```\n\n> **See Also:** For detailed sanitizer configuration, common issues, and advanced flags,\n> see the **address-sanitizer** and **undefined-behavior-sanitizer** technique skills.\n\n### Common Sanitizer Issues\n\n| Issue | Solution |\n|-------|----------|\n| `LD_PRELOAD` not set | Export `LD_PRELOAD` to point to `asan_with_fuzzer.so` |\n| Memory allocation failures | Set `ASAN_OPTIONS=allocator_may_return_null=1` |\n| Leak detection noise | Set `ASAN_OPTIONS=detect_leaks=0` |\n| Missing symbolizer | Set `ASAN_SYMBOLIZER_PATH` to `llvm-symbolizer` |\n\n## Advanced Usage\n\n### Tips and Tricks\n\n| Tip | Why It Helps |\n|-----|--------------|\n| Use `atheris.instrument_imports()` early | Ensures all imports are instrumented for coverage |\n| Start with small `max_len` | Faster initial fuzzing, gradually increase |\n| Use dictionaries for structured formats | Helps fuzzer understand format tokens |\n| Run multiple parallel instances | Better coverage exploration |\n\n### Custom Instrumentation\n\nFine-tune what gets instrumented:\n```python\nimport atheris\n\n# Instrument only specific modules\nwith atheris.instrument_imports():\n    import target_module\n# Don't instrument test harness code\n\ndef TestOneInput(data: bytes):\n    target_module.parse(data)\n```\n\n### Performance Tuning\n\n| Setting | Impact |\n|---------|--------|\n| `-max_len=N` | Smaller values = faster execution |\n| `-workers=N -jobs=N` | Parallel fuzzing for faster coverage |\n| `ASAN_OPTIONS=fast_unwind_on_malloc=0` | Better stack traces, slower execution |\n\n### UndefinedBehaviorSanitizer (UBSan)\n\nAdd UBSan to catch additional bugs:\n```bash\nexport CFLAGS=\"-fsanitize=address,undefined,fuzzer-no-link\"\nexport CXXFLAGS=\"-fsanitize=address,undefined,fuzzer-no-link\"\n```\n\nNote: Modify flags in Dockerfile if using containerized setup.\n\n## Real-World Examples\n\nTwo complete harnesses — a pure-Python parser and an HTTP response parser — are in\n[examples.md](examples.md).\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| No coverage increase | Poor seed corpus or target not instrumented | Add better seeds, verify `instrument_imports()` |\n| Slow execution | ASan overhead or large inputs | Reduce `max_len`, use `ASAN_OPTIONS=fast_unwind_on_malloc=1` |\n| Import errors | Modules imported before instrumentation | Move imports inside `instrument_imports()` context |\n| Segfault without ASan output | Missing `LD_PRELOAD` | Set `LD_PRELOAD` to `asan_with_fuzzer.so` path |\n| Build failures | Wrong compiler or missing flags | Verify `CC`, `CFLAGS`, and clang version |\n\n## Related Skills\n\n### Technique Skills\n\n| Skill | Use Case |\n|-------|----------|\n| **fuzz-harness-writing** | Detailed guidance on writing effective harnesses |\n| **address-sanitizer** | Memory error detection during fuzzing |\n| **undefined-behavior-sanitizer** | Catching undefined behavior in C extensions |\n| **coverage-analysis** | Measuring and improving code coverage |\n| **fuzzing-corpus** | Building and managing seed corpora |\n\n### Related Fuzzers\n\n| Skill | When to Consider |\n|-------|------------------|\n| **hypothesis** | Property-based testing with type-aware generation |\n| **python-afl** | AFL-style fuzzing for Python when Atheris isn't available |\n\n## Resources\n\n### Key External Resources\n\n**[Atheris GitHub Repository](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris)**\nOfficial repository with installation instructions, examples, and documentation for fuzzing both pure Python and native extensions.\n\n**[Native Extension Fuzzing Guide](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md)**\nComprehensive guide covering compilation flags, LD_PRELOAD setup, sanitizer configuration, and troubleshooting for Python C extensions.\n\n**[Continuously Fuzzing Python C Extensions](https:\u002F\u002Fblog.trailofbits.com\u002F2024\u002F02\u002F23\u002Fcontinuously-fuzzing-python-c-extensions\u002F)**\nTrail of Bits blog post covering CI\u002FCD integration, ClusterFuzzLite setup, and real-world examples of fuzzing Python C extensions in continuous integration pipelines.\n\n**[ClusterFuzzLite Python Integration](https:\u002F\u002Fgoogle.github.io\u002Fclusterfuzzlite\u002Fbuild-integration\u002Fpython-lang\u002F)**\nGuide for integrating Atheris fuzzing into CI\u002FCD pipelines using ClusterFuzzLite for automated continuous fuzzing.\n\n### Video Resources\n\nVideos and tutorials are available in the main Atheris documentation and libFuzzer resources.\n","# Atheris\n\nAtheris 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.\n\n## When to Use\n\n| Fuzzer | Best For | Complexity |\n|--------|----------|------------|\n| Atheris | Python code and C extensions | Low-Medium |\n| Hypothesis | Property-based testing | Low |\n| python-afl | AFL-style fuzzing | Medium |\n\n**Choose Atheris when:**\n- Fuzzing pure Python code with coverage guidance\n- Testing Python C extensions for memory corruption\n- Integration with libFuzzer ecosystem is desired\n- AddressSanitizer support is needed\n\n## Quick Start\n\n```python\nimport sys\nimport atheris\n\n@atheris.instrument_func\ndef TestOneInput(data: bytes):\n    if len(data) == 4:\n        if data[0] == 0x46:  # \"F\"\n            if data[1] == 0x55:  # \"U\"\n                if data[2] == 0x5A:  # \"Z\"\n                    if data[3] == 0x5A:  # \"Z\"\n                        raise RuntimeError(\"You caught me\")\n\ndef main():\n    atheris.Setup(sys.argv, TestOneInput)\n    atheris.Fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\nRun:\n```bash\nuv run python fuzz.py\n```\n\n## Installation\n\nAtheris supports 32-bit and 64-bit Linux, and macOS. We recommend fuzzing on Linux because it's simpler to manage and often faster.\n\n### Prerequisites\n\n- Python 3.7 or later\n- Recent version of clang (preferably [latest release](https:\u002F\u002Fgithub.com\u002Fllvm\u002Fllvm-project\u002Freleases))\n- For Docker users: [Docker Desktop](https:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-desktop\u002F)\n\n### Linux\u002FmacOS\n\n```bash\nuv init --bare   # once, if the harness directory is not yet a uv project\nuv add atheris\n```\n\n### Docker Environment (Recommended)\n\nFor a fully operational Linux environment with all dependencies configured:\n\n```dockerfile\n# https:\u002F\u002Fhub.docker.com\u002F_\u002Fpython\nARG PYTHON_VERSION=3.11\n\nFROM python:$PYTHON_VERSION-slim-bookworm\n\nRUN python --version\n\nRUN apt update && apt install -y \\\n    ca-certificates \\\n    wget \\\n    && rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\n# LLVM builds version 15-19 for Debian 12 (Bookworm)\n# https:\u002F\u002Fapt.llvm.org\u002Fbookworm\u002Fdists\u002F\nARG LLVM_VERSION=19\n\nRUN echo \"deb http:\u002F\u002Fapt.llvm.org\u002Fbookworm\u002F llvm-toolchain-bookworm-$LLVM_VERSION main\" > \u002Fetc\u002Fapt\u002Fsources.list.d\u002Fllvm.list\nRUN echo \"deb-src http:\u002F\u002Fapt.llvm.org\u002Fbookworm\u002F llvm-toolchain-bookworm-$LLVM_VERSION main\" >> \u002Fetc\u002Fapt\u002Fsources.list.d\u002Fllvm.list\nRUN wget -qO- https:\u002F\u002Fapt.llvm.org\u002Fllvm-snapshot.gpg.key > \u002Fetc\u002Fapt\u002Ftrusted.gpg.d\u002Fapt.llvm.org.asc\n\nRUN apt update && apt install -y \\\n    build-essential \\\n    clang-$LLVM_VERSION \\\n    && rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\nENV APP_DIR \"\u002Fapp\"\nRUN mkdir $APP_DIR\nWORKDIR $APP_DIR\n\nENV VIRTUAL_ENV \"\u002Fopt\u002Fvenv\"\nRUN python -m venv $VIRTUAL_ENV\nENV PATH \"$VIRTUAL_ENV\u002Fbin:$PATH\"\n\n# https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#step-1-compiling-your-extension\nENV CC=\"clang-$LLVM_VERSION\"\nENV CFLAGS \"-fsanitize=address,fuzzer-no-link\"\nENV CXX=\"clang++-$LLVM_VERSION\"\nENV CXXFLAGS \"-fsanitize=address,fuzzer-no-link\"\nENV LDSHARED=\"clang-$LLVM_VERSION -shared\"\nENV LDSHAREDXX=\"clang++-$LLVM_VERSION -shared\"\nENV ASAN_SYMBOLIZER_PATH=\"\u002Fusr\u002Fbin\u002Fllvm-symbolizer-$LLVM_VERSION\"\n\n# Allow Atheris to find fuzzer sanitizer shared libs\n# https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris#building-from-source\nRUN LIBFUZZER_LIB=$($CC -print-file-name=libclang_rt.fuzzer_no_main-$(uname -m).a) \\\n    python -m pip install --no-binary atheris atheris\n\n# https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#option-a-sanitizerlibfuzzer-preloads\nENV LD_PRELOAD \"$VIRTUAL_ENV\u002Flib\u002Fpython3.11\u002Fsite-packages\u002Fasan_with_fuzzer.so\"\n\n# 1. Skip memory allocation failures for now, they are common, and low impact (DoS)\n# 2. https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#leak-detection\nENV ASAN_OPTIONS \"allocator_may_return_null=1,detect_leaks=0\"\n\nCMD [\"\u002Fbin\u002Fbash\"]\n```\n\nBuild and run:\n```bash\ndocker build -t atheris .\ndocker run -it atheris\n```\n\n### Verification\n\n```bash\npython -c \"import atheris; print(atheris.__version__)\"\n```\n\n## Writing a Harness\n\n### Harness Structure for Pure Python\n\n```python\nimport sys\nimport atheris\n\n@atheris.instrument_func\ndef TestOneInput(data: bytes):\n    \"\"\"\n    Fuzzing entry point. Called with random byte sequences.\n\n    Args:\n        data: Random bytes generated by the fuzzer\n    \"\"\"\n    # Add input validation if needed\n    if len(data) \u003C 1:\n        return\n\n    # Call your target function\n    try:\n        your_target_function(data)\n    except ValueError:\n        # Expected exceptions should be caught\n        pass\n    # Let unexpected exceptions crash (that's what we're looking for!)\n\ndef main():\n    atheris.Setup(sys.argv, TestOneInput)\n    atheris.Fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Structured Input with FuzzedDataProvider\n\nA target taking several typed arguments wastes most of the fuzzer's inputs if the harness\nslices `data` by hand, because every mutation shifts the byte offsets of everything after it.\n`atheris.FuzzedDataProvider` splits one `bytes` input into typed values instead:\n\n```python\nfdp = atheris.FuzzedDataProvider(data)\nname = fdp.ConsumeUnicodeNoSurrogates(fdp.ConsumeIntInRange(0, 64))\nstrict = fdp.ConsumeBool()\n```\n\nSee [structured-input.md](structured-input.md) for the full method reference, the fixed-draw-\norder rule, and what each method returns once the buffer runs dry.\n\n### Harness Rules\n\n| Do | Don't |\n|----|-------|\n| Use `@atheris.instrument_func` for coverage | Forget to instrument target code |\n| Catch expected exceptions | Catch all exceptions indiscriminately |\n| Use `atheris.instrument_imports()` for libraries | Import modules after `atheris.Setup()` |\n| Keep harness deterministic | Use randomness or time-based behavior |\n\n> **See Also:** For detailed harness writing techniques, patterns for handling complex inputs,\n> and advanced strategies, see the **fuzz-harness-writing** technique skill.\n\n## Fuzzing Pure Python Code\n\nFor fuzzing broader parts of an application or library, use instrumentation functions:\n\n```python\nimport atheris\nwith atheris.instrument_imports():\n    import your_module\n    from another_module import target_function\n\ndef TestOneInput(data: bytes):\n    target_function(data)\n\natheris.Setup(sys.argv, TestOneInput)\natheris.Fuzz()\n```\n\n**Instrumentation Options:**\n- `atheris.instrument_func` - Decorator for single function instrumentation\n- `atheris.instrument_imports()` - Context manager for instrumenting all imported modules\n- `atheris.instrument_all()` - Instrument all Python code system-wide\n\n## Fuzzing Python C Extensions\n\nPython C extensions require compilation with specific flags for instrumentation and sanitizer support.\n\n### Environment Configuration\n\nIf using the provided Dockerfile, these are already configured. For local setup:\n\n```bash\nexport CC=\"clang\"\nexport CFLAGS=\"-fsanitize=address,fuzzer-no-link\"\nexport CXX=\"clang++\"\nexport CXXFLAGS=\"-fsanitize=address,fuzzer-no-link\"\nexport LDSHARED=\"clang -shared\"\n```\n\n### Example: Fuzzing cbor2\n\nInstall the extension from source:\n```bash\nCBOR2_BUILD_C_EXTENSION=1 uv add --no-binary-package cbor2 'cbor2==5.6.4'\n```\n\nThe `--no-binary-package` flag ensures the C extension is compiled locally with\ninstrumentation rather than pulled as a prebuilt wheel. Persist that choice with\n`no-binary-package = [\"cbor2\"]` under `[tool.uv]` in `pyproject.toml`, or a later\n`uv sync` can silently swap in an uninstrumented wheel.\n\nCreate `cbor2-fuzz.py`:\n```python\nimport sys\nimport atheris\n\n# _cbor2 ensures the C library is imported\nfrom _cbor2 import loads\n\ndef TestOneInput(data: bytes):\n    try:\n        loads(data)\n    except Exception:\n        # We're searching for memory corruption, not Python exceptions\n        pass\n\ndef main():\n    atheris.Setup(sys.argv, TestOneInput)\n    atheris.Fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\nRun:\n```bash\nuv run python cbor2-fuzz.py\n```\n\n> **Important:** When running locally (not in Docker), you must [set `LD_PRELOAD` manually](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md#option-a-sanitizerlibfuzzer-preloads).\n\n## Corpus Management\n\n### Creating Initial Corpus\n\n```bash\nmkdir corpus\n# Add seed inputs\necho \"test data\" > corpus\u002Fseed1\necho '{\"key\": \"value\"}' > corpus\u002Fseed2\n```\n\nRun with corpus:\n```bash\nuv run python fuzz.py corpus\u002F\n```\n\n### Corpus Minimization\n\nAtheris inherits corpus minimization from libFuzzer:\n```bash\nuv run python fuzz.py -merge=1 new_corpus\u002F old_corpus\u002F\n```\n\n> **See Also:** For corpus creation strategies, dictionaries, and seed selection,\n> see the **fuzzing-corpus** technique skill.\n\n## Running Campaigns\n\n### Basic Run\n\n```bash\nuv run python fuzz.py\n```\n\n### With Corpus Directory\n\n```bash\nuv run python fuzz.py corpus\u002F\n```\n\n### Common Options\n\n```bash\n# Run for 10 minutes\nuv run python fuzz.py -max_total_time=600\n\n# Limit input size\nuv run python fuzz.py -max_len=1024\n\n# Run with multiple workers\nuv run python fuzz.py -workers=4 -jobs=4\n```\n\n### Interpreting Output\n\n| Output | Meaning |\n|--------|---------|\n| `NEW    cov: X` | Found new coverage, corpus expanded |\n| `pulse  cov: X` | Periodic status update |\n| `exec\u002Fs: X` | Executions per second (throughput) |\n| `corp: X\u002FYb` | Corpus size: X inputs, Y bytes total |\n| `ERROR: libFuzzer` | Crash detected |\n\n## Sanitizer Integration\n\n### AddressSanitizer (ASan)\n\nAddressSanitizer is automatically integrated when using the provided Docker environment or when compiling with appropriate flags.\n\nFor local setup:\n```bash\nexport CFLAGS=\"-fsanitize=address,fuzzer-no-link\"\nexport CXXFLAGS=\"-fsanitize=address,fuzzer-no-link\"\n```\n\nConfigure ASan behavior:\n```bash\nexport ASAN_OPTIONS=\"allocator_may_return_null=1,detect_leaks=0\"\n```\n\n### LD_PRELOAD Configuration\n\nFor native extension fuzzing:\n```bash\nexport LD_PRELOAD=\"$(python -c 'import atheris; import os; print(os.path.join(os.path.dirname(atheris.__file__), \"asan_with_fuzzer.so\"))')\"\n```\n\n> **See Also:** For detailed sanitizer configuration, common issues, and advanced flags,\n> see the **address-sanitizer** and **undefined-behavior-sanitizer** technique skills.\n\n### Common Sanitizer Issues\n\n| Issue | Solution |\n|-------|----------|\n| `LD_PRELOAD` not set | Export `LD_PRELOAD` to point to `asan_with_fuzzer.so` |\n| Memory allocation failures | Set `ASAN_OPTIONS=allocator_may_return_null=1` |\n| Leak detection noise | Set `ASAN_OPTIONS=detect_leaks=0` |\n| Missing symbolizer | Set `ASAN_SYMBOLIZER_PATH` to `llvm-symbolizer` |\n\n## Advanced Usage\n\n### Tips and Tricks\n\n| Tip | Why It Helps |\n|-----|--------------|\n| Use `atheris.instrument_imports()` early | Ensures all imports are instrumented for coverage |\n| Start with small `max_len` | Faster initial fuzzing, gradually increase |\n| Use dictionaries for structured formats | Helps fuzzer understand format tokens |\n| Run multiple parallel instances | Better coverage exploration |\n\n### Custom Instrumentation\n\nFine-tune what gets instrumented:\n```python\nimport atheris\n\n# Instrument only specific modules\nwith atheris.instrument_imports():\n    import target_module\n# Don't instrument test harness code\n\ndef TestOneInput(data: bytes):\n    target_module.parse(data)\n```\n\n### Performance Tuning\n\n| Setting | Impact |\n|---------|--------|\n| `-max_len=N` | Smaller values = faster execution |\n| `-workers=N -jobs=N` | Parallel fuzzing for faster coverage |\n| `ASAN_OPTIONS=fast_unwind_on_malloc=0` | Better stack traces, slower execution |\n\n### UndefinedBehaviorSanitizer (UBSan)\n\nAdd UBSan to catch additional bugs:\n```bash\nexport CFLAGS=\"-fsanitize=address,undefined,fuzzer-no-link\"\nexport CXXFLAGS=\"-fsanitize=address,undefined,fuzzer-no-link\"\n```\n\nNote: Modify flags in Dockerfile if using containerized setup.\n\n## Real-World Examples\n\nTwo complete harnesses — a pure-Python parser and an HTTP response parser — are in\n[examples.md](examples.md).\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| No coverage increase | Poor seed corpus or target not instrumented | Add better seeds, verify `instrument_imports()` |\n| Slow execution | ASan overhead or large inputs | Reduce `max_len`, use `ASAN_OPTIONS=fast_unwind_on_malloc=1` |\n| Import errors | Modules imported before instrumentation | Move imports inside `instrument_imports()` context |\n| Segfault without ASan output | Missing `LD_PRELOAD` | Set `LD_PRELOAD` to `asan_with_fuzzer.so` path |\n| Build failures | Wrong compiler or missing flags | Verify `CC`, `CFLAGS`, and clang version |\n\n## Related Skills\n\n### Technique Skills\n\n| Skill | Use Case |\n|-------|----------|\n| **fuzz-harness-writing** | Detailed guidance on writing effective harnesses |\n| **address-sanitizer** | Memory error detection during fuzzing |\n| **undefined-behavior-sanitizer** | Catching undefined behavior in C extensions |\n| **coverage-analysis** | Measuring and improving code coverage |\n| **fuzzing-corpus** | Building and managing seed corpora |\n\n### Related Fuzzers\n\n| Skill | When to Consider |\n|-------|------------------|\n| **hypothesis** | Property-based testing with type-aware generation |\n| **python-afl** | AFL-style fuzzing for Python when Atheris isn't available |\n\n## Resources\n\n### Key External Resources\n\n**[Atheris GitHub Repository](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris)**\nOfficial repository with installation instructions, examples, and documentation for fuzzing both pure Python and native extensions.\n\n**[Native Extension Fuzzing Guide](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fatheris\u002Fblob\u002Fmaster\u002Fnative_extension_fuzzing.md)**\nComprehensive guide covering compilation flags, LD_PRELOAD setup, sanitizer configuration, and troubleshooting for Python C extensions.\n\n**[Continuously Fuzzing Python C Extensions](https:\u002F\u002Fblog.trailofbits.com\u002F2024\u002F02\u002F23\u002Fcontinuously-fuzzing-python-c-extensions\u002F)**\nTrail of Bits blog post covering CI\u002FCD integration, ClusterFuzzLite setup, and real-world examples of fuzzing Python C extensions in continuous integration pipelines.\n\n**[ClusterFuzzLite Python Integration](https:\u002F\u002Fgoogle.github.io\u002Fclusterfuzzlite\u002Fbuild-integration\u002Fpython-lang\u002F)**\nGuide for integrating Atheris fuzzing into CI\u002FCD pipelines using ClusterFuzzLite for automated continuous fuzzing.\n\n### Video Resources\n\nVideos and tutorials are available in the main Atheris documentation and libFuzzer resources.\n",{"name":5,"type":23,"description":7},"fuzzer","main","321ccfe628eca0d314b0ee4eaffcdd8a05639aaf","plugins\u002Ftesting-handbook-skills\u002Fskills\u002Fatheris",0,"https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills","https:\u002F\u002Fgithub.com\u002Fbongkage","2026-11-06 12:15:06",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add bongkage\u002Ftrailofbits-skills --skill atheris",{"tool":37,"command":38},"bunx","bunx skills add bongkage\u002Ftrailofbits-skills --skill atheris",{"tool":40,"command":41},"pnpm","pnpm dlx skills add bongkage\u002Ftrailofbits-skills --skill atheris","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftesting-handbook-skills\u002Fskills\u002Fatheris\u002FSKILL.md",true,[45,51,57,61],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"agents\u002Fopenai.yaml","REFERENCE","参考文档",128,"https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftesting-handbook-skills\u002Fskills\u002Fatheris\u002Fagents\u002Fopenai.yaml",{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"assets\u002Ftrail-of-bits-mark.svg","ASSET","资产文件",3084,"https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftesting-handbook-skills\u002Fskills\u002Fatheris\u002Fassets\u002Ftrail-of-bits-mark.svg",{"path":58,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":59,"sourceHtmlUrl":60},"examples.md",1280,"https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftesting-handbook-skills\u002Fskills\u002Fatheris\u002Fexamples.md",{"path":62,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":63,"sourceHtmlUrl":64},"structured-input.md",3368,"https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftesting-handbook-skills\u002Fskills\u002Fatheris\u002Fstructured-input.md",[66,73,80,87,94,101],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M7CHJAESZRWKJXFQG55BMNAA","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fzeroize-audit\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7CHJ543G42A9GQC3PJE4F4V","yara-rule-authoring","Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.","https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fyara-authoring\u002Fskills\u002Fyara-rule-authoring\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M7CHHYVFS1AKDTH3YDS1Y4K4","writing-lean-proofs","Writes and reviews structured Lean 4 proofs and designs Lean libraries following Mathlib conventions. Use when proving theorems in Lean, formalizing mathematics or specifications in Lean 4, defining new types or definitions in a Lean library, reviewing Lean proofs for readability and maintainability, refactoring long tactic proofs into lemmas, filling in sorry placeholders in a Lean development, setting up CI or linters for a Lean project, diagnosing slow proofs or maxHeartbeats timeouts, or writing custom tactics, macros, or linters.","https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fwriting-lean-proofs\u002Fskills\u002Fwriting-lean-proofs\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M7CHHQXA39M4965MV2RMM5YS","vulnerability-triage-brocards","This skill should be used when the user asks to \"triage a vulnerability report\", \"assess a CVE\", \"evaluate a bug bounty submission\", \"decide if a finding is valid\", \"review a security finding\", \"dismiss a vulnerability\", \"should we fix this CVE\", \"prioritize a vulnerability report\", or needs to determine whether an incoming vulnerability report warrants investigation. Applies 7 brocards (rules of thumb) to systematically accept, dismiss, or request more information on vulnerability reports, or needs to filter raw findings from agentic vulnerability discovery pipelines before human review.","https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fvulnerability-triage-brocards\u002Fskills\u002Fvulnerability-triage-brocards\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M7CHHJVQC2ZG2M310GXT0T42","variant-analysis","Hunts for the other instances of a bug already found — the variants of one root cause across a codebase. Use immediately after a vulnerability, logic bug, or bad pattern turns up in a specific file and the question becomes where else it occurs, including the bare conversational form (\"are there others like this?\", \"is this the same bug?\"). Also for generalizing one known instance into a CodeQL or Semgrep query for its whole pattern family, and for triaging a set of look-alike candidates against a known root cause. Not for initial discovery with no bug in hand.","https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fvariant-analysis\u002Fskills\u002Fvariant-analysis\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":18},"01M7CHHC1GM5GH585ZWGP7D03P","vector-forge","Mutation-driven test vector generation. Finds implementations of a cryptographic algorithm or protocol, runs mutation testing to identify escaped mutants, then generates new test vectors that deliberately exercise the uncovered code paths. Compares before\u002Fafter mutation kill rates to prove vector effectiveness. Use when generating cryptographic test vectors, measuring Wycheproof coverage gaps, finding escaped mutants via mutation testing, creating cross-implementation test suites, or improving test vector coverage for crypto primitives.","https:\u002F\u002Fgithub.com\u002Fbongkage\u002Ftrailofbits-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftrailmark\u002Fskills\u002Fvector-forge\u002FSKILL.md",[],[]]