mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
[pitboss] phase 03: Track J.1 + Track L.1 — DESERIALIZE corpus + Java/Python/PHP/Ruby adapters
This commit is contained in:
parent
01fcaab310
commit
9dc60b51c0
33 changed files with 1625 additions and 53 deletions
22
tests/dynamic_fixtures/deserialize/python/benign.py
Normal file
22
tests/dynamic_fixtures/deserialize/python/benign.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
"""Phase 03 (Track J.1) — Python deserialize benign fixture.
|
||||
|
||||
Wraps `pickle.Unpickler` with a `find_class` override that hard-codes
|
||||
a tiny allowlist. A gadget chain in the payload trips
|
||||
`UnpicklingError` before any code runs, so no Deserialize probe
|
||||
fires.
|
||||
"""
|
||||
import io
|
||||
import pickle
|
||||
|
||||
ALLOWED = {("builtins", "list"), ("builtins", "dict"), ("builtins", "int")}
|
||||
|
||||
|
||||
class RestrictedUnpickler(pickle.Unpickler):
|
||||
def find_class(self, module: str, name: str):
|
||||
if (module, name) not in ALLOWED:
|
||||
raise pickle.UnpicklingError(f"blocked: {module}.{name}")
|
||||
return super().find_class(module, name)
|
||||
|
||||
|
||||
def run(blob: bytes):
|
||||
return RestrictedUnpickler(io.BytesIO(blob)).load()
|
||||
11
tests/dynamic_fixtures/deserialize/python/vuln.py
Normal file
11
tests/dynamic_fixtures/deserialize/python/vuln.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
"""Phase 03 (Track J.1) — Python deserialize vuln fixture.
|
||||
|
||||
`pickle.loads` accepts arbitrary classes; a gadget chain inside the
|
||||
payload runs straight through `__reduce__` without bumping into any
|
||||
allowlist.
|
||||
"""
|
||||
import pickle
|
||||
|
||||
|
||||
def run(blob: bytes):
|
||||
return pickle.loads(blob)
|
||||
Loading…
Add table
Add a link
Reference in a new issue