-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ci): make the Atheris fuzz job capable of failing + repair its dead targets (LAB-1140) #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
27Bslash6
wants to merge
6
commits into
main
Choose a base branch
from
lab-1140-atheris-honest-red
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ac0c150
fix(ci): make Atheris fuzz job capable of failing (LAB-1140)
27Bslash6 585f84e
fix(fuzz): repair Atheris targets that never survived startup (LAB-1140)
27Bslash6 230f1c5
fix(fuzz): apply expert-panel findings (LAB-1140)
27Bslash6 e916dbf
fix(fuzz): make the oracles survive -O; clear the pip CVE reddening C…
92f177a
docs(fuzz): say why the oracles raise instead of asserting (LAB-1140)
d6bd3d1
docs(ci): sync the pip constraint comment the bump left stale (LAB-1140)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!/usr/bin/env python3 | ||
| """Atheris fuzz target for ByteStorage (Python → Rust FFI boundary). | ||
|
|
||
| This guards the FFI binding contract: roundtrip fidelity, and that hostile | ||
| envelopes surface as clean ValueError — never an interpreter crash or a | ||
| pyo3 PanicException. Coverage-guided exploration of the Rust decode surface | ||
| itself lives in `cargo fuzz run byte_storage_decompress` (rust/fuzz/); the | ||
| native .so is invisible to Atheris' bytecode instrumentation, so this | ||
| target's mutation is unguided by design. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import contextlib | ||
| import importlib | ||
| import sys | ||
|
|
||
| import atheris | ||
|
|
||
| # Pre-import third-party deps so instrument_imports() below skips them | ||
| # (already in sys.modules = not instrumented) — we fuzz cachekit's code; | ||
| # third-party coverage is not the goal, and atheris-instrumented third-party | ||
| # bytecode is a proven startup-crash class: instrumented pydantic segfaults | ||
| # CPython 3.11 in _decorators.merge_seqs during pydantic_settings' | ||
| # CLI-provider model construction (pulled in transitively via | ||
| # cachekit.hiredis_compat). That SIGSEGV killed every nightly target during | ||
| # startup, before a single fuzz iteration (LAB-1140/LAB-2528). Optional deps | ||
| # use suppress: absent is fine, instrumented is the trap. | ||
| for _mod in ( | ||
| "pydantic", | ||
| "pydantic_settings", | ||
| "numpy", | ||
| "pandas", | ||
| "pyarrow", | ||
| "redis", | ||
| "msgpack", | ||
| "xxhash", | ||
| "prometheus_client", | ||
| ): | ||
| with contextlib.suppress(ImportError): | ||
| importlib.import_module(_mod) | ||
|
|
||
| with atheris.instrument_imports(): | ||
| from cachekit._rust_serializer import ByteStorage | ||
|
|
||
| _STORAGE = ByteStorage("msgpack") | ||
|
|
||
|
|
||
| def TestOneInput(data: bytes) -> None: | ||
| """Fuzz the ByteStorage store/retrieve FFI roundtrip and hostile-envelope decode.""" | ||
| fdp = atheris.FuzzedDataProvider(data) | ||
|
|
||
| if fdp.ConsumeBool(): | ||
| # Roundtrip: store must retrieve byte-identically. | ||
| payload = bytes(fdp.ConsumeBytes(fdp.ConsumeIntInRange(0, 4096))) | ||
| envelope = _STORAGE.store(payload, "msgpack") | ||
| retrieved, fmt = _STORAGE.retrieve(envelope) | ||
| # Explicit raise, not assert: -O / PYTHONOPTIMIZE strips assert, which | ||
| # would leave this target reporting no crashes while verifying nothing. | ||
| if bytes(retrieved) != payload: | ||
| raise AssertionError("ByteStorage roundtrip failed") | ||
| if fmt != "msgpack": | ||
| raise AssertionError(f"format tag corrupted: {fmt}") | ||
| else: | ||
| # Attacker-controlled envelope (cache content is untrusted): must | ||
| # raise cleanly, never crash the interpreter. | ||
| try: | ||
| _STORAGE.retrieve(bytes(fdp.ConsumeBytes(fdp.remaining_bytes()))) | ||
| except ValueError: | ||
| pass | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| atheris.Setup(sys.argv, TestOneInput) | ||
| atheris.Fuzz() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.