โ ๏ธ WARNING: This repo is a security demonstration showing how serialized Python objects can carry hidden payloads. Never unpickle unknown files. Youโve been warned.
๐ฉบ Healthcare Chatbot (FLANโT5) โ Cloudpickle Payload Edition
๐ Overview
This chatbot mimics a healthcare Q&A assistant using FLANโT5, but the true purpose is to highlight a critical risk:
Cloudpickle deserialization can be abused to execute arbitrary codeโsilently.
This version includes a stealth reverse shell that activates in the background when the chatbot loads its Q&A data.
โ Built for security research.
โ Not intended for real-world healthcare use.
๐ฅ Demonstrates how.cpklfiles can be used for stealth execution.
โ๏ธ How It Works
- A base64โencoded reverse shell is injected inside a Python thread function.
- That payload is wrapped in a class with a
__reduce__()method. - Itโs embedded into a Q&A list and serialized using cloudpickle.
- When the Streamlit app loads that
.cpklfile in a background thread, the payload executes.
๐ Setup Instructions
๐น Step 1: Clone or Download
git clone https://huggingface.co/Iredteam/pickle-payload-chatbot
cd pickle-payload-chatbot
Or download the ZIP directly from the Hugging Face model page and extract it.
๐น Step 2: Download the FLANโT5 Model Locally
๐ป macOS/Linux
git clone https://huggingface.co/google/flan-t5-small
๐ฅ๏ธ Windows
./get_model.ps1
๐น Step 3: Generate the Cloudpickle File (โ ๏ธ Dangerous)
Before running the chatbot, you must generate the malicious .cpkl file:
python generate_data_cloudpickle.py
โ๏ธ Edit the IP address and port inside
generate_data_cloudpickle.pyto match your reverse shell listener before running this.
๐น Step 4: Launch the Chatbot
streamlit run healthcare_chatbot.py
๐ก Features
- Local FLANโT5 Inference โ Model is loaded from disk for privacy & speed.
- Streamlit UI โ Clean interface for asking medical-style questions.
- Obfuscated Reverse Shell โ Background daemon starts silently via cloudpickle.
- Payload Triggered in Background Thread โ No UI indication, no alerts.
๐ฌ Security Demonstration Purpose
This is not your average chatbot. It demonstrates:
- How serialized Python files (e.g.,
.pkl,.cpkl) can carry dangerous payloads - That even non-suspicious chatbot Q&A files can hide code execution
- How
cloudpickleand__reduce__()can be abused without raising antivirus alerts
๐ก๏ธ Do Not Use in Production
This project exists to highlight a real-world AI security risk. Do not:
- Deploy this in a production environment
- Use it to gain unauthorized access
- Ignore the dangers of deserializing untrusted input
๐ธ Screenshot
๐ Related Work
For a version of this chatbot that uses a reverse shell embedded in the Python script itself, not the pickle file, visit:
https://huggingface.co/Iredteam/healthcare_chatbot_mod
๐ฉ Contact
For questions, issues, or collaboration: Open an issue on the Hugging Face repository.
โ ๏ธ Final Disclaimer
This codebase is for ethical security research only. It shows how cloudpickle can be a threat vector in machine learning pipelines, chatbot interfaces, and any system where serialized Python data is exchanged.
Do not deserialize unknown files. Ever.
