Repository navigation
OSS-Fuzz: Add new fuzzer/corpus/dicts/options/scripts targets deserialisers #62
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
arthurscchan
wants to merge
1
commit into
python:main
Choose a base branch
from
arthurscchan:library-fuzzers-fuzz-deserialisers
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,27 @@ | ||
| (dp0 | ||
| Valpha | ||
| p1 | ||
| I1 | ||
| sVbeta | ||
| p2 | ||
| (lp3 | ||
| F2.5 | ||
| aVx | ||
| p4 | ||
| ac_codecs | ||
| encode | ||
| p5 | ||
| (Vy | ||
| p6 | ||
| Vlatin1 | ||
| p7 | ||
| tp8 | ||
| Rp9 | ||
| aNaI01 | ||
| aI00 | ||
| asVgamma | ||
| p10 | ||
| (I1 | ||
| I2 | ||
| tp11 | ||
| s. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@ | ||
| Jë2¤ø. |
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,41 @@ | ||
| (dp0 | ||
| Vlist | ||
| p1 | ||
| (lp2 | ||
| I1 | ||
| a(lp3 | ||
| I2 | ||
| a(lp4 | ||
| I3 | ||
| a(dp5 | ||
| Vdeep | ||
| p6 | ||
| (I4 | ||
| I5 | ||
| tp7 | ||
| saaasVset | ||
| p8 | ||
| c__builtin__ | ||
| set | ||
| p9 | ||
| ((lp10 | ||
| I1 | ||
| aI2 | ||
| aI3 | ||
| atp11 | ||
| Rp12 | ||
| sVfrozenset | ||
| p13 | ||
| c__builtin__ | ||
| frozenset | ||
| p14 | ||
| ((lp15 | ||
| Va | ||
| p16 | ||
| aVb | ||
| p17 | ||
| aVc | ||
| p18 | ||
| atp19 | ||
| Rp20 | ||
| s. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,12 @@ | ||
| (dp0 | ||
| Vkey | ||
| p1 | ||
| Vvalue | ||
| p2 | ||
| sVn | ||
| p3 | ||
| (lp4 | ||
| I1 | ||
| aI2 | ||
| aI3 | ||
| as. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # marshal type codes (with and without the 0x80 REF flag) and structure tokens | ||
| "N" | ||
| "F" | ||
| "T" | ||
| "S" | ||
| "i" | ||
| "I" | ||
| "f" | ||
| "g" | ||
| "x" | ||
| "y" | ||
| "A" | ||
| "s" | ||
| "t" | ||
| "u" | ||
| "r" | ||
| "e" | ||
| "c" | ||
| "(" | ||
| "[" | ||
| "{" | ||
| "<" | ||
| ">" | ||
| ")" | ||
| "0" | ||
| "C" | ||
| "w" | ||
| "\x80" | ||
| "\x81" | ||
| "\x84" | ||
| "\x88" | ||
| "\x89" | ||
| "\x8a" | ||
| "\x8d" | ||
| "\x8e" | ||
| "\x91" | ||
| "\xa0" | ||
| "\xa1" | ||
| "\xa2" | ||
| "\xa3" | ||
| "\xa4" | ||
| "\xa5" | ||
| "\xa6" | ||
| "\xa7" | ||
| "\xa8" | ||
| "\xa9" | ||
| "\xc0" | ||
| "\xc1" | ||
| "\xe0" | ||
| "\xe9" | ||
| "ab" | ||
| "aaa" | ||
| "\x00\x01" |
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,71 @@ | ||
| # pickle opcode bytes (protocol 0-5) and typical atoms | ||
| "\x80" | ||
| "\x80\x02" | ||
| "\x80\x04" | ||
| "\x80\x05" | ||
| "(" | ||
| ")" | ||
| "]" | ||
| "}" | ||
| "." | ||
| "t" | ||
| "G" | ||
| "X" | ||
| "U" | ||
| "T" | ||
| "V" | ||
| "S" | ||
| "C" | ||
| "B" | ||
| "L" | ||
| "K" | ||
| "M" | ||
| "J" | ||
| "F" | ||
| "I" | ||
| "o" | ||
| "i" | ||
| "R" | ||
| "P" | ||
| "Q" | ||
| "N" | ||
| "e" | ||
| "a" | ||
| "s" | ||
| "u" | ||
| "r" | ||
| "p" | ||
| "q" | ||
| "h" | ||
| "j" | ||
| "0" | ||
| "1" | ||
| "g" | ||
| "f" | ||
| "\x8a" | ||
| "\x8b" | ||
| "\x8c" | ||
| "\x8d" | ||
| "\x8e" | ||
| "\x8f" | ||
| "\x90" | ||
| "\x91" | ||
| "\x92" | ||
| "\x93" | ||
| "\x94" | ||
| "\x95" | ||
| "\x96" | ||
| "\x97" | ||
| "\x98" | ||
| "builtins" | ||
| "__main__" | ||
| "copyreg" | ||
| "_reconstructor" | ||
| "collections" | ||
| "OrderedDict" | ||
| "defaultdict" | ||
| "encode" | ||
| "loads" | ||
| "\x8cbuiltins" | ||
| "\x8cdict" | ||
| "\x94" |
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,30 @@ | ||
| """Fuzz marshal.loads() over untrusted bytes. | ||
|
|
||
| marshal is the deserialiser behind .pyc files and marshal.dumps()/loads(); | ||
| unmarshalling attacker-supplied bytes must stay memory-safe: invalid type | ||
| tags, negative or oversized length fields, dangling ref tags and malformed | ||
| code objects are all attacker-controlled. Input is capped at 1 MiB; the | ||
| deserialisation itself is expected to reject malformed streams with | ||
| EOFError/ValueError/TypeError/RecursionError/MemoryError -- anything else | ||
| propagates and aborts the fuzzer as a finding. | ||
| """ | ||
| import marshal | ||
|
|
||
| MAX_MARSHAL_TEST_SIZE = 0x100000 # 1 MiB, matching the other size-capped targets | ||
|
|
||
|
|
||
| def FuzzerRunOne(FuzzerInput): | ||
| if len(FuzzerInput) > MAX_MARSHAL_TEST_SIZE: | ||
| return | ||
| try: | ||
| marshal.loads(FuzzerInput) | ||
| except EOFError: | ||
| pass | ||
| except ValueError: | ||
| pass | ||
| except TypeError: | ||
| pass | ||
| except RecursionError: | ||
| pass | ||
| except MemoryError: | ||
| pass | ||
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,31 @@ | ||
| """Fuzz the C unpickler over untrusted bytes. | ||
|
|
||
| pickle is the classic "never unpickle untrusted data" surface: the load | ||
| loop lives in the C accelerator _pickle.Unpickler. We subclass it only to | ||
| disable find_class, so mutated payloads cannot import arbitrary modules or | ||
| execute code inside the fuzzer process while every opcode-handling code | ||
| path (stack/memo manipulation, string and framing parsing, object | ||
| reconstruction of built-in types) stays covered. Invalid streams raise | ||
| UnpicklingError/EOFError, and object reconstruction (REDUCE, SETSTATE, | ||
| APPEND on built-in containers) can raise arbitrary exceptions -- those are | ||
| expected for attacker bytes; memory-safety bugs in the opcode machinery | ||
| still crash the sanitiser. | ||
| """ | ||
| import _pickle | ||
| import io | ||
|
|
||
| MAX_PICKLE_TEST_SIZE = 0x100000 # 1 MiB | ||
|
|
||
|
|
||
| class FuzzerUnpickler(_pickle.Unpickler): | ||
| def find_class(self, module, name): | ||
| raise _pickle.UnpicklingError("find_class is disabled") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I'm concerned this will just be additional noise, and these aren't particularly important issues most of the time. |
||
|
|
||
|
|
||
| def FuzzerRunOne(FuzzerInput): | ||
| if len(FuzzerInput) > MAX_PICKLE_TEST_SIZE: | ||
| return | ||
| try: | ||
| FuzzerUnpickler(io.BytesIO(FuzzerInput)).load() | ||
| except Exception: | ||
| pass | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, we explicitly note:
I'm worried this will just be additional noise.