Vulnerability in Keras Model.load_model Leading to Arbitrary Local File Loading and SSRF
Key facts
- Attack vector
- Adjacent network
- Privileges required
- Low
- User interaction
- Passive
- Attack complexity
- High
- Attack requirements
- Present
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · Low · Low
- Fix status
- Partial Red Hat: 2 without a fix
Attack profile from CVSS 4.0 · CNA. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-502.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| keras-team | Keras | before 3.12.0 | 3.12.0 | Patch available | CNA |
| — | keras (PyPI) | before 3.12.0 | 3.12.0 | Patch available | GHSA-mq84-hjqx-cwf2 |
- Keras Vendorkeras-team Affected before 3.12.0 Fixed in 3.12.0 Patch available CNA
- keras (PyPI) Vendor— Affected before 3.12.0 Fixed in 3.12.0 Patch available GHSA-mq84-hjqx-cwf2
Remediation
- Fix · CNA Keras (Keras) Fixed in 3.12.0
- Fix · GHSA-mq84-hjqx-cwf2 keras (PyPI) Fixed in 3.12.0 Advisory →
Vendor assessments
Red Hat
Red Hat rating: Moderate. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat OpenShift AI (RHOAI) | Affected | No fix yet: Fix deferred |
| Red Hat Trusted Artifact Signer | Affected | No fix yet: Fix deferred |
Timeline
- 2026-10-02 Threatist record created from CVE-2025-12058
- 2026-10-03 Alias added: GHSA-mq84-hjqx-cwf2
References
More keras-team vulnerabilities
- TI-2025-31626 Deserialization of untrusted data in keras-team Keras CVSS 3.1CRITICAL 9.8
- TI-2026-10715 Deserialization of Untrusted Data in keras-team/keras CVSS 3.1CRITICAL 9.8
- TI-2026-01159 Safe Mode Bypass in keras-team/keras CVSS 3.0HIGH 8.8
- TI-2025-08001 Keras safe_mode bypass allows arbitrary code execution when loading a malicious model. CVSS 4.0HIGH 8.6
- TI-2026-10199 Path Traversal in keras-team/keras CVSS 3.0HIGH 8.1
- TI-2025-11591 Path Traversal Vulnerability in keras-team/keras via Tar Archive Extraction in keras.utils.get_file() CVSS 3.0HIGH 8.0
Sources
- CVE-2025-12058 · CVE Program
- CVE-2025-12058 · NVD
- FIRST EPSS
- GHSA-mq84-hjqx-cwf2 · GitHub Advisory Database · CC BY 4.0
- CVE-2025-12058 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences