This commit is contained in:
Eli Peter 2026-06-05 10:16:30 -05:00 committed by GitHub
parent 55247b7fcd
commit 991c84a1eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
1464 changed files with 225448 additions and 1985 deletions

View 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()

View 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)