Keras is vulnerable to arbitrary local file loading and Server-Side Request Forgery
MediumCVE-2025-12058 · Published Oct 29, 2025 · updated Sep 10, 2026
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| keras PyPI | < 3.12.0 | 3.12.0 |
Details and references
The Keras.Model.load_model method, including when executed with the intended security mitigation safe_mode=True, is vulnerable to arbitrary local file loading and Server-Side Request Forgery (SSRF). This vulnerability stems from the way the StringLookup layer is handled during model loading from a specially crafted .keras archive. The constructor for the StringLookup layer accepts a vocabulary argument that can specify a local file path or a remote file path. * Arbitrary Local File Read: An attacker can create a malicious .keras file that embeds a local path in the StringLookup layer's configuration. When the model is loaded, Keras will attempt to read the content of the specified local file and incorporate it into the model state (e.g., retrievable via get_vocabulary()), allowing an attacker to read arbitrary local files on the hosting system. * Server-Side Request Forgery (SSRF): Keras utilizes tf.io.gfile for file operations. Since tf.io.gfile supports remote filesystem handlers (such as GCS and HDFS) and HTTP/HTTPS protocols, the same mechanism can be leveraged to fetch content from arbitrary network endpoints on the server's behalf, resulting in an SSRF condition. The security issue is that the feature allowing external path loading was not properly restricted by the safe_mode=True flag, which was intended to prevent such unintended data access.
- CVSS 4.0
- CVSS:4.0/AV:A/AC:H/AT:P/PR:L/UI:P/VC:H/VI:L/VA:L/SC:H/SI:L/SA:L/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
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-502, CWE-918
- Also known as
- CVE-2025-12058, GHSA-qg93-c7p6-gg7f, PYSEC-2026-1487
More Keras advisories
All Keras| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Oct 172025 | Keras framework vulnerable to deserialization of untrusted data CVE-2025-49655Critical9.8fixed in 3.11.3 | Critical9.8 | 3.11.3 |
| Dec 22025 | Keras Directory Traversal Vulnerability CVE-2025-12060High9.8fixed in 3.12.0 | High9.8 | 3.12.0 |
| Sep 192025 | The Keras `Model.load_model` method **silently** ignores `safe_mode=True` and allows arbitrary code execution when a `.h5`/`.hdf5` file is loaded. CVE-2025-9905Highfixed in 3.11.3 | High | 3.11.3 |
| Sep 192025 | Keras is vulnerable to Deserialization of Untrusted Data CVE-2025-9906High7.3fixed in 3.11.0 | High7.3 | 3.11.0 |
| Aug 122025 | Keras vulnerable to CVE-2025-1550 bypass via reuse of internal functionality CVE-2025-8747High8.8fixed in 3.11.0 | High8.8 | 3.11.0 |
| Feb 18 | Keras has a Local File Disclosure via HDF5 External Storage During Keras Weight Loading CVE-2026-1669High7.1fixed in 3.12.1, 3.13.2 | High7.1 | 3.12.1, 3.13.2 |