β οΈ SECURITY RESEARCH: Joblib Deserialization RCE Vulnerability
WARNING: This repository contains a malicious model file for security research purposes only.
π΄ CRITICAL SECURITY NOTICE
This is a Proof of Concept (PoC) demonstrating a critical Remote Code Execution (RCE) vulnerability in .joblib model files through unsafe pickle deserialization.
DO NOT load this model file unless you understand the security implications.
π Vulnerability Summary
| Property | Value |
|---|---|
| Vulnerability Type | Arbitrary Code Execution (ACE) / Remote Code Execution (RCE) |
| Affected Format | .joblib |
| Attack Vector | Unsafe pickle deserialization |
| CVSS Score | 9.8 (Critical) |
| Trigger Point | joblib.load() |
| Status | Submitted to bug bounty program |
π― Description
The .joblib serialization format, commonly used for saving scikit-learn models and other Python objects, relies on Python's pickle module for deserialization. The pickle protocol is inherently unsafe when deserializing untrusted data because it can execute arbitrary Python code.
This PoC demonstrates how an attacker can:
- Create a malicious
.joblibfile with embedded Python code - Upload it to a model repository (HuggingFace, ModelZoo, etc.)
- Achieve Remote Code Execution when a victim loads the file
How It Works
The exploit leverages Python's __reduce__ method, which pickle calls during deserialization:
class MaliciousModel:
def __reduce__(self):
# Returns (callable, arguments)
# Pickle will execute: exec(malicious_code)
return (exec, (malicious_code,))
When joblib.load('weaponized_model.joblib') is called, the malicious code executes immediately.
π Repository Contents
weaponized_model.joblib- Malicious model file (PoC)load_model_demo.py- Safe demonstration script with user confirmationREPRODUCTION.md- Detailed step-by-step reproduction guide
π¬ Reproduction Steps
Prerequisites
# Python 3.x required
pip install joblib numpy
Quick Test
import joblib
# β οΈ WARNING: This triggers arbitrary code execution!
model = joblib.load('weaponized_model.joblib')
Safe Demonstration
Use the provided demo script with user confirmation:
python load_model_demo.py
What Happens?
When you run the code:
- β
Immediate code execution upon
joblib.load() - β System information is displayed (OS, Python version, user, etc.)
- β Demonstrates full code execution capabilities
- β No user interaction required after loading
Expected: Model loads silently without side effects
Actual: Arbitrary Python code executes during deserialization
π₯ Security Impact
An attacker exploiting this vulnerability can:
| Impact | Description |
|---|---|
| π Remote Code Execution | Execute arbitrary Python code on victim's system |
| π File System Access | Read, write, or delete files |
| π Credential Theft | Access environment variables, config files, SSH keys |
| π‘ Data Exfiltration | Send sensitive data to attacker-controlled servers |
| π¦ Malware Delivery | Download and execute additional payloads |
| π Lateral Movement | Pivot to other systems in the network |
| π£ Supply Chain Attack | Poison widely-used models affecting thousands of users |
π Real-World Attack Scenarios
Scenario 1: Model Repository Poisoning
- Attacker creates malicious model disguised as legitimate pre-trained model
- Uploads to HuggingFace, GitHub, or other model repositories
- Victim downloads and loads:
model = joblib.load('model.joblib') - RCE achieved - attacker gains shell access
Scenario 2: Jupyter Notebook Attack
- Malicious
.joblibfile shared in collaborative notebook - Data scientist loads model in trusted environment
- Code executes with scientist's credentials and access
Scenario 3: Automated ML Pipeline
- ML pipeline automatically downloads and loads models
- Malicious model in pipeline triggers on scheduled run
- Compromises production systems
π‘οΈ Mitigation & Defense
For Users
- β
Never load
.joblibfiles from untrusted sources - β Verify model provenance with cryptographic signatures
- β
Use safer formats like
.safetensors, ONNX, or TensorFlow SavedModel - β Sandbox model loading in isolated containers/VMs
- β Scan files with static analysis tools before loading
For Developers
- β
Deprecate
.joblibfor untrusted models - β Implement integrity checks (SHA256 hashes, signatures)
- β Add security warnings to documentation
- β Provide migration paths to safer formats
- β Educate users about pickle security risks
For Platform Operators
- β Scan uploaded models for malicious pickle payloads
- β
Warn users when downloading
.joblibfiles - β Implement sandboxing for model previews
- β Require verified badges for trusted uploaders
π Technical Details
Exploit Mechanism
# Attacker creates this:
class ExploitModel:
def __reduce__(self):
return (exec, ("import os; os.system('malicious_command')",))
# Victim runs this:
import joblib
model = joblib.load('malicious.joblib') # Code executes here!
Why This Works
joblib.dump()usespickle.dump()internally- Pickle serializes the
__reduce__method joblib.load()callspickle.load()- Pickle calls
__reduce__()and executes returned callable exec(malicious_code)runs with victim's privileges
Affected Components
- joblib: All versions (inherent to pickle design)
- scikit-learn: Models saved with
joblib - pickle: Python's built-in serialization module
- Any library using joblib for persistence
π References & Resources
- Python Pickle Security Warning - Official Python docs
- Joblib Documentation - Joblib serialization docs
- OWASP: Deserialization Vulnerabilities
- SafeTensors Format - Secure alternative
- CWE-502: Deserialization of Untrusted Data
βοΈ Responsible Disclosure
This vulnerability disclosure follows responsible security practices:
- β Reported to appropriate bug bounty program
- β Created for legitimate security research
- β Intended to raise awareness and improve security
- β Not exploited maliciously
π Educational Use Only
This PoC is provided exclusively for:
| β Permitted | β Prohibited |
|---|---|
| Security research | Malicious attacks |
| Educational purposes | Unauthorized access |
| Defensive testing | Data theft |
| Vulnerability disclosure | System compromise |
| Academic study | Malware distribution |
π Disclaimer
This repository is for security research and educational purposes only.
- The author is not responsible for any misuse of this information
- Users must comply with all applicable laws and regulations
- Unauthorized access to computer systems is illegal
- Always obtain proper authorization before security testing
π€ Author
Created for security research and bug bounty program submission.
Submission Date: January 19, 2026
Program: Model File Vulnerability Bug Bounty (Beta)
π License
MIT License - For research and educational purposes only.
π Additional Information
For more details on the vulnerability, reproduction steps, and technical analysis, see:
REPRODUCTION.md- Detailed reproduction guideload_model_demo.py- Safe demonstration script
Remember: With great power comes great responsibility. Use this knowledge to make systems more secure, not to harm them.