Incident report

Keras Arbitrary Code Injection via Malicious Lambda Layers in Legacy Models

CVE-2024-3660 (published April 16, 2024, disclosed by Oligo Security and JFrog) highlighted arbitrary code execution in TensorFlow Keras (`< 2.13`) when deserializing `.h5` or Keras models containing weaponized `Lambda` layers. Because Keras Lambda layers serialize arbitrary marshaled Python bytecode directly inside the neural network graph definition, calling `load_model()` executed attacker commands automatically on load. Legacy enterprise ML pipelines continuing to load third-party H5 models faced silent supply-chain compromise. Upgrading to Keras 2.13+ with `safe_mode=True` enabled by default and scanning model layers remediated the baseline risk.

Incident record

Reported
Severity
Critical
Vector
Supply Chain
Affected system type
TensorFlow / Keras H5 & SavedModel Pipelines
Reference
CVE-2024-3660
Reference URI
https://nvd.nist.gov/vuln/detail/CVE-2024-3660

Inspect in Interactive Incidents Hub

Defensive lesson

Prohibit Keras Lambda layers in third-party model ingestion pipelines, enforce safe_mode=True, and scan all H5/SavedModel artifacts in CI.

Referenced techniques