CVE-2025-9905: The Keras `Model.load_model` method **silently** ignores `safe_mode=True` and allows arbitrary code execution when a `.h5`/`.hdf5` file is loaded.
When a model in the .h5
(or .hdf5
) format is loaded using the Keras Model.load_model
method, the safe_mode=True
setting is silently ignored without any warning or error. This allows an attacker to execute arbitrary code on the victim’s machine with the same privileges as the Keras application. This report is specific to the .h5
/.hdf5
file format. The attack works regardless of the other parameters passed to load_model
and does not require any sophisticated technique—.h5
and .hdf5
files are simply not checked for unsafe code execution.
From this point on, I will refer only to the .h5
file format, though everything equally applies to .hdf5
.
References
Code Behaviors & Features
Detect and mitigate CVE-2025-9905 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →