Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- security-research
|
| 5 |
+
- messagepack
|
| 6 |
+
- msgpack
|
| 7 |
+
- model-file-vulnerability
|
| 8 |
+
- huntr-mfv
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# MessagePack Unpacker Trigger Backdoor PoC
|
| 12 |
+
|
| 13 |
+
This repository contains a benign security research proof of concept for a
|
| 14 |
+
MessagePack model-file vulnerability report.
|
| 15 |
+
|
| 16 |
+
Files:
|
| 17 |
+
|
| 18 |
+
- `control_msgpack_classifier.msgpack`
|
| 19 |
+
- `malicious_msgpack_unpacker_trigger.msgpack`
|
| 20 |
+
- `reproduce.py`
|
| 21 |
+
|
| 22 |
+
The malicious MessagePack file is loaded with `msgpack.Unpacker(...)`. It behaves
|
| 23 |
+
like the control file for normal inputs, but hidden tensor values in the file
|
| 24 |
+
change model output during inference for a trigger input.
|
| 25 |
+
|
| 26 |
+
Tested runtime:
|
| 27 |
+
|
| 28 |
+
- `msgpack==1.1.2`
|
| 29 |
+
- `numpy==2.4.6`
|
| 30 |
+
- trigger entrypoint: `msgpack.Unpacker(...); numpy inference`
|
| 31 |
+
|
| 32 |
+
Scanner result:
|
| 33 |
+
|
| 34 |
+
- `modelscan==0.8.8`
|
| 35 |
+
- result: `No issues found!`
|
| 36 |
+
- skipped reason: `Model Scan did not scan file`
|
| 37 |
+
|
| 38 |
+
Public files:
|
| 39 |
+
|
| 40 |
+
- Control: `https://huggingface.co/hacnho/msgpack-unpacker-trigger-backdoor-poc/resolve/main/control_msgpack_classifier.msgpack`
|
| 41 |
+
- Malicious: `https://huggingface.co/hacnho/msgpack-unpacker-trigger-backdoor-poc/resolve/main/malicious_msgpack_unpacker_trigger.msgpack`
|
| 42 |
+
- Reproducer: `https://huggingface.co/hacnho/msgpack-unpacker-trigger-backdoor-poc/resolve/main/reproduce.py`
|
| 43 |
+
|
| 44 |
+
Reproduction:
|
| 45 |
+
|
| 46 |
+
```bash
|
| 47 |
+
python -m venv /tmp/msgpack-unpacker-trigger-poc-venv
|
| 48 |
+
. /tmp/msgpack-unpacker-trigger-poc-venv/bin/activate
|
| 49 |
+
pip install 'numpy' 'msgpack==1.1.2' 'modelscan==0.8.8'
|
| 50 |
+
|
| 51 |
+
curl -L -o control_msgpack_classifier.msgpack \
|
| 52 |
+
https://huggingface.co/hacnho/msgpack-unpacker-trigger-backdoor-poc/resolve/main/control_msgpack_classifier.msgpack
|
| 53 |
+
curl -L -o malicious_msgpack_unpacker_trigger.msgpack \
|
| 54 |
+
https://huggingface.co/hacnho/msgpack-unpacker-trigger-backdoor-poc/resolve/main/malicious_msgpack_unpacker_trigger.msgpack
|
| 55 |
+
curl -L -o reproduce.py \
|
| 56 |
+
https://huggingface.co/hacnho/msgpack-unpacker-trigger-backdoor-poc/resolve/main/reproduce.py
|
| 57 |
+
|
| 58 |
+
python reproduce.py control_msgpack_classifier.msgpack malicious_msgpack_unpacker_trigger.msgpack
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
Expected output:
|
| 62 |
+
|
| 63 |
+
```json
|
| 64 |
+
"control_trigger": {
|
| 65 |
+
"preds": [1, 1]
|
| 66 |
+
}
|
| 67 |
+
"malicious_trigger": {
|
| 68 |
+
"preds": [1, 0]
|
| 69 |
+
}
|
| 70 |
+
"no_issues_found": true
|
| 71 |
+
```
|