CVE-2025-9905 Arbitary Code execution in Keras load_model()
HighCVSS 7.3
EPSS 0.22%
- Published
- Updated
- Exploit status
- No public exploit known
Description
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.
Affected products
| Product | Affected versions | Fixed in |
|---|---|---|
| pypi keras(PyPI) | >= 3.0.0, < 3.11.3 | 3.11.3 |
| pypi keras(PyPI) | = 3.0.0 | No fix listed |
| pypi keras(PyPI) | = 3.0.1 | No fix listed |
| pypi keras(PyPI) | = 3.0.2 | No fix listed |
| pypi keras(PyPI) | = 3.0.3 | No fix listed |
| pypi keras(PyPI) | = 3.0.4 | No fix listed |
| pypi keras(PyPI) | = 3.0.5 | No fix listed |
| pypi keras(PyPI) | = 3.1.0 | No fix listed |
| pypi keras(PyPI) | = 3.1.1 | No fix listed |
| pypi keras(PyPI) | = 3.10.0 | No fix listed |
| pypi keras(PyPI) | = 3.11.0 | No fix listed |
| pypi keras(PyPI) | = 3.11.1 | No fix listed |
| pypi keras(PyPI) | = 3.11.2 | No fix listed |
| pypi keras(PyPI) | = 3.2.0 | No fix listed |
| pypi keras(PyPI) | = 3.2.1 | No fix listed |
| pypi keras(PyPI) | = 3.3.0 | No fix listed |
| pypi keras(PyPI) | = 3.3.1 | No fix listed |
| pypi keras(PyPI) | = 3.3.2 | No fix listed |
| pypi keras(PyPI) | = 3.3.3 | No fix listed |
| pypi keras(PyPI) | = 3.4.0 | No fix listed |
| pypi keras(PyPI) | = 3.4.1 | No fix listed |
| pypi keras(PyPI) | = 3.5.0 | No fix listed |
| pypi keras(PyPI) | = 3.6.0 | No fix listed |
| pypi keras(PyPI) | = 3.7.0 | No fix listed |
| pypi keras(PyPI) | = 3.8.0 | No fix listed |
Show 9 more
| Product | Affected versions | Fixed in |
|---|---|---|
| pypi keras(PyPI) | = 3.9.0 | No fix listed |
| pypi keras(PyPI) | = 3.9.1 | No fix listed |
| pypi keras(PyPI) | = 3.9.2 | No fix listed |
| azure linux keras(Azure Linux:3.0) | < 3.3.3-4 | 3.3.3-4 |
| debian/keras(Debian:11) | All versions | No fix listed |
| debian/keras(Debian:11) | = 2.3.1+dfsg-3 | No fix listed |
| debian/keras(Debian:11) | = 2.3.1+dfsg2-1 | No fix listed |
| keras-team Keras | >= 3.0.0, <= 3.11.2 | No fix listed |
| Keras | >= 3.0.0, < 3.11.3 | 3.11.3 |
References
- github.com exploit vendor-advisory
- nvd.nist.gov third-party-advisory vendor-advisory
- github.com issue-tracking patch
- github.com product
- github.com
- MSRC Security Update Guide vendor-advisory
- CBL-Mariner Releases vendor-advisory
- security-tracker.debian.org vendor-advisory
- github.com