Skip to content
KerasGHSA-mq84-hjqx-cwf2

Keras is vulnerable to arbitrary local file loading and Server-Side Request Forgery

MediumCVE-2025-12058 · Published Oct 29, 2025 · updated Sep 10, 2026

GitHub advisory

Affected versions

PackageAffectedFixed in
keras
PyPI
< 3.12.03.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
DateAdvisory
Oct 172025Keras framework vulnerable to deserialization of untrusted data
CVE-2025-49655Critical9.8fixed in 3.11.3
Dec 22025Keras Directory Traversal Vulnerability
CVE-2025-12060High9.8fixed in 3.12.0
Sep 192025The 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
Sep 192025Keras is vulnerable to Deserialization of Untrusted Data
CVE-2025-9906High7.3fixed in 3.11.0
Aug 122025Keras vulnerable to CVE-2025-1550 bypass via reuse of internal functionality
CVE-2025-8747High8.8fixed in 3.11.0
Feb 18Keras has a Local File Disclosure via HDF5 External Storage During Keras Weight Loading
CVE-2026-1669High7.1fixed in 3.12.1, 3.13.2

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.