CVE Catalog

CVE-2025-9905

HighCVSS 7.3
Published: Updated: Translated: NVD NIST

Exploitation Probability (EPSS)

Low risk
0.22%

12th percentile - higher than 12% 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 specially crafted .h5/.hdf5 model archive using the Lambda layer with pickled code triggers arbitrary Python code execution because safe_mode=True is not honored when reading .h5 archives.

Risk Assessment

Loading a malicious 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 .h5/.hdf5 models from untrusted sources and prefer the newer .keras format. Update Keras to a patched version and verify model integrity before loading.

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 .h5/.hdf5 model archive that, when loaded via Model.load_model, will trigger arbitrary code to be executed. This is achieved by crafting a special .h5 archive file that uses the Lambda layer feature of keras which allows arbitrary Python code in the form of pickled code. The vulnerability comes from the fact that the safe_mode=True option is not honored when reading .h5 archives. Note that the .h5/.hdf5 format is a legacy format supported by Keras 3 for backwards compatibility.

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