CVE Catalog

CVE-2025-9906

HighCVSS 7.3
Published: Updated: Translated: NVD NIST

Exploitation Probability (EPSS)

Low risk
0.20%

10th percentile - higher than 10% of all known CVEs

Summary

The Keras Model.load_model method can be exploited to achieve arbitrary code execution even with safe_mode=True. A crafted config.json inside a .keras archive invokes keras.config.enable_unsafe_deserialization() to disable safe mode, after which the Lambda layer with pickled code executes arbitrary Python code.

Risk Assessment

Loading a malicious .keras model can lead to arbitrary code execution in the context of the application loading the model, risking system compromise. This is especially relevant for environments loading untrusted ML models.

Recommendation

Do not load .keras models from untrusted sources and inspect the archive contents (config.json) before loading. Update Keras to a patched version.

Other vulnerabilities in Keras

See all
Original NVD description (English source)

The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True. One can create a specially crafted .keras model archive that, when loaded via Model.load_model, will trigger arbitrary code to be executed. This is achieved by crafting a special config.json (a file within the .keras archive) that will invoke keras.config.enable_unsafe_deserialization() to disable safe mode. Once safe mode is disable, one can use the Lambda layer feature of keras, which allows arbitrary Python code in the form of pickled code. Both can appear in the same archive. Simply the keras.config.enable_unsafe_deserialization() needs to appear first in the archive and the Lambda with arbitrary code needs to be second.

Vulnerability data from NVD (NIST) · CISA KEV · EPSS