Downloads · 30 days
0
optimus-fulcria/modelscan-h5-bypass-poc
modelscan-h5-bypass-poc is a machine learning model from optimus-fulcria. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
ModelScan v0.8.8's H5LambdaDetectScan scanner only checks top-level layers in the H5 model config for classname == "Lambda". Lambda layers nested inside sub-models or wrapper layers are not detected.
Downloads · 30 days
0
Access
Public
Updated Feb 21, 2026
Repo size
12.5 KB
Likes
0
Public
Click a slice to open those files.
.h512.5 KB · 46%
From the Hugging Face model README
ModelScan v0.8.8's H5LambdaDetectScan scanner only checks top-level layers in the H5 model config for class_name == "Lambda". Lambda layers nested inside sub-models or wrapper layers are not detected.
modelscan/scanners/h5/scan.py lines 105-130:
def _get_keras_h5_operator_names(self, model: Model) -> Optional[List[Any]]:
with h5py.File(model.get_stream()) as model_hdf5:
model_config = json.loads(model_hdf5.attrs.get("model_config", {}))
layers = model_config.get("config", {}).get("layers", {})
lambda_layers = []
for layer in layers:
if layer.get("class_name", {}) == "Lambda": # Only top-level!
lambda_layers.append(...)
The scanner iterates model_config["config"]["layers"] at the top level only. It does not:
layer field inside wrapper layers (TimeDistributed, Bidirectional)nested_model_h5_bypass.h5)Lambda is placed inside a Functional sub-model:
[Dense, Functional] -> No Lambda detectedFunctional.config.layers contains [InputLayer, Lambda]wrapper_layer_h5_bypass.h5)Lambda is wrapped inside a TimeDistributed layer:
[Dense, TimeDistributed] -> No Lambda detectedTimeDistributed.config.layer is a LambdaWhen loading with tf.keras.models.load_model('model.h5', safe_mode=False):
load_model() reads model_config from HDF5 attributemodel_from_config() processes layers recursivelyFunctional.from_config() calls process_layer() for each nested layerLambda.from_config() calls python_utils.func_load()func_load() does: base64.decode() -> marshal.loads() -> types.FunctionType() -> ACE$ modelscan -p nested_model_h5_bypass.h5
No issues found!
$ modelscan -p wrapper_layer_h5_bypass.h5
No issues found!
$ modelscan -p normal_lambda.h5 # (top-level Lambda for comparison)
Total Issues: 1 (MEDIUM: Use of unsafe operator 'Lambda')
An attacker can craft a malicious .h5 model file that:
Replace the top-level-only layer check with recursive traversal of all layers, including nested models and wrapper layers.