Skip to content
FlawDB
Sign in
Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

CVE-2025-12058

MEDIUM 5.9EPSS 44%

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

Mitigation

  • Upgrade keras to 3.12.0 or later.

Who should check

  • Projects that depend on PyPI package keras (< 3.12.0)
  • Anyone running Keras < 3.12.0

Vulnerability facts

Affected
keras < 3.12.0
Fixed in
3.12.0
Exploited in the wild
Not in CISA KEV
Public exploit / PoC
None known
Remote exploitation
Not remotely exploitable (local or adjacent access needed)
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:LOpen in CVSS calculator
Show all 11 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
EPSS
0.61% chance of exploitation in 30 days (percentile 44, 2026-11-26)
CWE
CWE-502
Published
Modified

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

Package / productAffectedFixedSource
PyPI keras< 3.12.03.12.0osv
Keras< 3.12.0—cvelist

Check your systems with an agent

Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.

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.

References

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-26).

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.

Sponsors