Downloads · 30 days
0
rez0/keras-vds-safemode-bypass-poc
keras-vds-safemode-bypass-poc is a machine learning model from rez0. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras.
Security Research - Responsible Disclosure via huntr
Downloads · 30 days
0
Access
Public
Updated Feb 23, 2026
Repo size
12.3 KB
Likes
0
Public
Click a slice to open those files.
.py18.6 KB · 53%
From the Hugging Face model README
Security Research - Responsible Disclosure via huntr
Keras <= 3.13.2 _verify_dataset() only checks dataset.external (ExternalLink)
but NOT dataset.is_virtual (VirtualDataset). A malicious model using HDF5 Virtual
Datasets transparently reads data from external H5 files on the victim's filesystem,
bypassing safe_mode=True.
Impact: Exfiltration of HDF5 files from victim's machine (other models, datasets, cached weights) when loading a malicious model.
| Loading Method | VDS Works? | Notes |
|---|---|---|
load_model('model/') unzipped dir | YES | HuggingFace Hub format |
model.load_weights('file.weights.h5') | YES | Always disk-backed |
load_model('model.h5') legacy format | YES | Direct H5 load |
HuggingFace from_pretrained() | YES | Downloads to disk |
Large .keras zip (>available RAM) | YES | Extracted to temp dir |
KERAS_BACKEND=numpy python3 poc_final.py
# keras/src/saving/saving_lib.py, _verify_dataset()
# Checks this: dataset.external -> None for VDS (PASSES!)
# Misses this: dataset.is_virtual -> True for VDS (NOT CHECKED)
# VDS reads from: dataset.virtual_sources() -> external file refs
Add dataset.is_virtual check to _verify_dataset():
if dataset.is_virtual:
raise ValueError("Virtual datasets referencing external files are not allowed")