Arbitary Code execution in Keras load_model() (Keras-team Keras)
At a glance
- Source
- NVD
- EPSS
- EPSS 0.22 % · percentile 14 ()
- State
- PUBLISHED
- Published
- Updated
- Assigner
- Affected products
- Keras-team · Keras
- NVD status
- Analyzed
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.
Weaknesses (CWE)
- CWE-913 — Improper Control of Dynamically-Managed Code Resources
Credits
- Gabriele Digregorio finder
References
Scores
| Version | Score | Vector | Scored by |
|---|---|---|---|
| CVSS 4.0 | HIGH 7.3 | CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H | |
| CVSS 4.0 | HIGH 7.3 | CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X | NVD · cve-coordination@google.com (Secondary) |
| CVSS 3.1 | HIGH 7.3 | CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H | NVD · nvd@nist.gov (Primary) |
Advisories
- GHSA-36rr-ww3j-vrjv — The Keras `Model.load_model` method **silently** ignores `safe_mode=True` and allows arbitrary code execution when a `.h5`/`.hdf5` file is loaded.
- PYSEC-2025-123 — The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True.
European references
- ENISA EUVD · EUVD-2025-30277
- GCVE · GCVE-0-2025-9905
CERT-FR advisories
- CERTFR-2026-AVI-1486 — Multiples vulnérabilités dans les produits VMware · cert.ssi.gouv.fr
Affected configurations (NVD CPE)
cpe:2.3:a:keras:keras:*:*:*:*:*:*:*:*≥ 3.0.0 < 3.11.3
Affected products
| Product | Affected versions |
|---|---|
Keras-team · Keraskeras | affected : ≥ 3.0.0 ≤ 3.11.2 Other versions : unaffected |
Sources
| Source | Licence |
|---|---|
| CVE List (CVEProject cvelistV5) | CVE Program Terms of Use |
| EPSS (FIRST.org) | FIRST — attribution requested |
| ENISA EUVD | ENISA — reproduction authorised, source acknowledged |
| CERT-FR (ANSSI) | Licence Ouverte / Etalab 2.0 |
| NVD (NIST) via fkie-cad/nvd-json-data-feeds | Public domain — this product uses data from the NVD API but is not endorsed or certified by the NVD |