KerasGHSA-48g7-3x6r-xfhp
Arbitrary Code Execution via Crafted Keras Config for Model Loading
Fix: upgrade to 3.9.0 or later
Impact
The Keras Model.load_model function permits arbitrary code execution, even with safe_mode=True, through a manually constructed, malicious .keras archive. By altering the config.json file within the archive, an attacker can specify arbitrary Python modules and functions, along with their arguments, to be loaded and executed during model loading.
Patches
This problem is fixed starting with version 3.9.
Workarounds
Only load models from trusted sources and model archives created with Keras.
References
- https://www.cve.org/cverecord?id=CVE-2025-1550
- https://github.com/keras-team/keras/pull/20751
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| keras PyPI | >= 3.0.0, < 3.9.0 | 3.9.0 |
Details and references
- CVSS 4.0
- CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-94
- Also known as
- CVE-2025-1550, PYSEC-2025-122
- github.com/keras-team/keras/security/advisories/GHSA-48g7-3x6r-xfhp
- nvd.nist.gov/vuln/detail/CVE-2025-1550
- github.com/keras-team/keras/pull/20751
- github.com/keras-team/keras/commit/e67ac8ffd0c883bec68eb65bb52340c7f9d3a903
- github.com/keras-team/keras
- github.com/keras-team/keras/releases/tag/v3.9.0
- github.com/pypa/advisory-database/tree/main/vulns/keras/PYSEC-2025-122.yaml
- towerofhanoi.it/writeups/cve-2025-1550