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

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.9
- **CVSS:** 5.9 (v4.0, CNA) `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`
- **CVSS metrics:** Attack vector: Adjacent network; Attack complexity: High; Attack requirements: Present; Privileges required: Low; User interaction: Passive; Confidentiality impact: High; Integrity impact: Low; Availability impact: Low; Confidentiality impact on other systems: High; Integrity impact on other systems: Low; Availability impact on other systems: Low
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.61% (percentile 44, 2026-11-28)
- **CWE:** CWE-502
- **Aliases:** GHSA-mq84-hjqx-cwf2, GHSA-qg93-c7p6-gg7f, PYSEC-2026-1487
- **Published:** 2025-10-29T08:48:29.689Z
- **Modified:** 2026-10-19T13:10:00.110Z

## Who should check

- Projects that depend on PyPI package keras (\< 3.12.0)
- Anyone running Keras \< 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.

## Affected and fixed versions

- PyPI `keras`: affected \< 3.12.0; fixed 3.12.0 (osv)
- Keras: \< 3.12.0 (cvelist)

## Mitigation

- Upgrade keras to 3.12.0 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-12058. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-12058.md
Affected: keras < 3.12.0
Fixed in: 3.12.0

Steps:
1. Search this machine and project for keras (PyPI), Keras: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-12058 being exploited?

There is no confirmed exploitation: CVE-2025-12058 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.61% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2025-12058?

Medium: CVSS 5.9 (v4.0, scored by CNA). Not remotely exploitable (local or adjacent access needed). A user has to take an action, such as opening a link, for the attack to work. The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2025-12058?

keras \< 3.12.0.

### Is there a fix for CVE-2025-12058?

Yes. Fixed in 3.12.0. Upgrade keras to 3.12.0 or later.

### How do I check if I'm affected by CVE-2025-12058?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/keras-team/keras/security/advisories/GHSA-qg93-c7p6-gg7f>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2025-12058>
- vendor: <https://github.com/advisories/GHSA-mq84-hjqx-cwf2>
- patch: <https://github.com/keras-team/keras/pull/21751>
- patch: <https://github.com/keras-team/keras/commit/61ac8c1e51862c471dee7b49029c356f55531487>
- other: <https://github.com/keras-team/keras>
- other: <https://www.cve.org/CVERecord?id=CVE-2025-12058>
- other: <https://pypi.org/project/keras>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-12058>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-mq84-hjqx-cwf2> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/PYSEC-2026-1487> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2025-12058> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-12058>
