Instructions to use djmolby/tensorflow-savedmodel-printv2-modelscan-bypass-poc with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TF-Keras
How to use djmolby/tensorflow-savedmodel-printv2-modelscan-bypass-poc with TF-Keras:
# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy), and from_pretrained_keras was removed in huggingface_hub 1.0. # See https://github.com/keras-team/tf-keras for more details. # !pip install "huggingface_hub<1.0" tf_keras from huggingface_hub import from_pretrained_keras model = from_pretrained_keras("djmolby/tensorflow-savedmodel-printv2-modelscan-bypass-poc") - Notebooks
- Google Colab
- Kaggle
You need to agree to share your Hugging Face 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 deliberately malicious TensorFlow SavedModel published for authorized security research / coordinated disclosure (huntr / ProtectAI). Access is gated and manually reviewed. Do not run or serve this model on any system you care about.
Log in or Sign Up to review the conditions and access this model content.
β οΈ Security PoC β malicious TensorFlow SavedModel (ModelScan bypass β ACE)
Deliberately malicious TensorFlow SavedModel (.pb) for coordinated
vulnerability disclosure.
What it demonstrates
ModelScan's TensorFlow SavedModel scanner (SavedModelTensorflowOpScan) treats
only the two literal ops ReadFile and WriteFile as unsafe. Every other
legitimate TensorFlow op is whitelisted:
if op in unsafe_operators: # {"ReadFile","WriteFile"} -> HIGH
...
elif op not in all_safe_operators: # unknown/custom op -> MEDIUM
...
else: # any other real TF op
continue # -> treated as SAFE
The PrintV2 op accepts output_stream="file://<path>", giving an
arbitrary file write of attacker-controlled bytes to an attacker-controlled
path. Because the op is named PrintV2 (not WriteFile), ModelScan reports the
model as clean β yet running/serving it writes the file, which escalates to
code execution (append to ~/.bashrc, /etc/cron.d/*, ~/.ssh/authorized_keys).
Target format
TensorFlow SavedModel β saved_model.pb (protobuf GraphDef) inside the
SavedModel directory. The malicious op lives in the graph's function library.
Files
malicious_savedmodel/β looks like a benignx -> 2xmodel; hides aPrintV2file-write sinkcontrol_savedmodel/β same file write viaWriteFile(ModelScan flags HIGH)build_tf_poc.pyβ generatorverify_savedmodel.py/trigger_savedmodel.pyβ scan + execute helpers
Reproduce
pip install tensorflow==2.21.0 'modelscan[tensorflow]'
# 1) BYPASS β scanner sees nothing on the malicious model
modelscan -p malicious_savedmodel/ # -> No issues found π
# 2) CONTROL β same write via WriteFile, correctly flagged
modelscan -p control_savedmodel/ # -> HIGH (Unsafe operator WriteFile)
# 3) Run the "clean" model like normal inference -> arbitrary file write -> RCE
python trigger_savedmodel.py malicious_savedmodel
Evidence
1. ModelScan bypass β PrintV2 file-write model is clean; WriteFile control is HIGH:
2. File write β code execution β the benign-looking model writes an attacker file on inference; sourcing it executes code:
Remediation
ModelScan should not rely on a two-name allowlist. It should flag the full set
of filesystem/network/IO-capable TF ops (PrintV2 with a file:///http://
stream, Save, SaveV2, MergeV2Checkpoints, MatchingFiles, dataset/IO
readers, etc.), and inspect dangerous op attributes (e.g. PrintV2.output_stream).
- Downloads last month
- -

