Rammadaeus's picture
Upload README.md with huggingface_hub
72bfb36 verified

PARSeqTokenizer Arbitrary File Read PoC

Vulnerability: PARSeqTokenizer.set_vocabulary() in keras-hub calls open(vocabulary, "r") on config-supplied string path without any safe_mode check or path validation.

Files

  • malicious_model.keras — Crafted .keras ZIP with PARSeqTokenizer config pointing vocabulary to /etc/passwd
  • poc.py — Full PoC script demonstrating the vulnerability

Reproduction

pip install keras keras-hub tensorflow
python poc.py

The PoC creates a malicious .keras file, loads it with keras.saving.load_model(safe_mode=True), and demonstrates that /etc/passwd contents are read and stored in the tokenizer's vocabulary attribute.

Impact

An attacker publishes a malicious .keras model to HuggingFace/Kaggle. A victim loads it. The attacker-controlled vocabulary path causes arbitrary file reads on the victim's system. File contents are exfiltrated via tokenizer.vocabulary / tokenizer.get_vocabulary().