CVE-2025-12058
Python vulnerability analysis and mitigation

Overview

The Keras.Model.loadmodel method contains a vulnerability (CVE-2025-12058) that allows arbitrary local file loading and Server-Side Request Forgery (SSRF), even when using the intended security mitigation safemode=True. The vulnerability was discovered in October 2025 and affects the StringLookup layer handling during model loading from specially crafted .keras archives (NVD).

Technical details

The vulnerability stems from the way the StringLookup layer is handled during model loading. The constructor accepts a vocabulary argument that can specify local or remote file paths. When loading a malicious .keras file with embedded local paths in the StringLookup layer's configuration, Keras attempts to read the specified local file content and incorporate it into the model state. Additionally, since Keras uses tf.io.gfile for file operations which supports remote filesystem handlers (GCS, HDFS) and HTTP/HTTPS protocols, this can be exploited for SSRF attacks. The vulnerability has been assigned a CVSS v4.0 score of 5.9 (Medium) with 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 (NVD).

Impact

The vulnerability has two main impact vectors: 1) Arbitrary Local File Read - attackers can read arbitrary local files on the hosting system through the model state, and 2) Server-Side Request Forgery (SSRF) - attackers can make the server fetch content from arbitrary network endpoints, potentially bypassing network security controls (NVD).

Mitigation and workarounds

A fix has been implemented that modifies StringLookup and IntegerLookup to embed vocabularies loaded from files directly into the .keras model archive, making the archive self-contained and removing dependencies on external vocabulary files. The fix also includes a security check to prevent loading arbitrary files when safe_mode is enabled (Github PR).

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-61385CRITICAL9.6
  • PythonPython
  • pg8000
NoYesOct 27, 2025
CVE-2025-62727HIGH7.5
  • PythonPython
  • starlette
NoYesOct 28, 2025
CVE-2025-54384MEDIUM6.3
  • PythonPython
  • ckan
NoYesOct 29, 2025
CVE-2025-12058MEDIUM5.9
  • PythonPython
  • keras
NoYesOct 29, 2025
CVE-2025-40843MEDIUM5.9
  • PythonPython
  • codechecker
NoYesOct 28, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management