Skip to main content

Keras CVE-2025-12058

MEDIUM
Deserialization of Untrusted Data (CWE-502)
2025-10-29 cve-coordination@google.com
5.9
CVSS 4.0 · Vendor: google
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Craft malicious .keras with StringLookup vocabulary path/URL
  2. Delivery
    Distribute via model hub or share with victim
  3. Exploit
    Victim loads model via load_model (safe_mode=True)
  4. Execution
    tf.io.gfile reads local file or fetches remote URL
  5. Impact
    Exfiltrate file contents or trigger server-side SSRF

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A08:2025 - Software or Data Integrity Failures
ASVS 5.0
V1 - Encoding and Sanitization Safe deserialization, type allowlists
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Initial Access

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires a victim to load an attacker-controlled .keras archive via Keras's load_model (or saving.load_model) where the embedded StringLookup layer's 'vocabulary' argument is set to a local filesystem path or a remote URI handled by tf.io.gfile (e.g. file paths, GCS, HDFS, or HTTP/HTTPS endpoints). Critically, the default mitigation safe_mode=True does NOT prevent this, so no non-default configuration is needed on the victim side. The primary limiting factor is the supply-chain/trust step: the attacker must get the target to load an untrusted model file; impact is bounded to arbitrary local file read (incorporated into model state) and SSRF to endpoints reachable from the host - it is not remote code execution. SSRF reach additionally depends on the host having the relevant network access and gfile handlers (GCS/HDFS/HTTP) available.

Impact

This is a moderate-severity deserialization-class flaw (CWE-502) in Keras model loading, scored CVSS 4.0 5.9 by the reporter. The supplied CVSS 4.0 vector (AV:A/AC:H/AT:P/PR:L/UI:P) paints a fairly constrained picture - adjacent network, high complexity, a specific attack requirement, low privileges and passive user interaction - which pulls the score down despite the high confidentiality impact (VC:H, SC:H). No EPSS score, KEV listing, or public POC was provided, so there is no public exploit identified at time of analysis and no evidence of active exploitation; the risk is primarily latent rather than imminent. The most important signal lives in the description rather than the metrics: the mitigation users rely on (safe_mode=True) does NOT block this path, so environments that believed they were protected are not. I disagree with the reporter's AV:A/AC:H framing - malicious .keras files are typically distributed over the network (model hubs, downloads, shared artifacts) and loaded without special conditions, so I assess this closer to AV:N/AC:L with UI:R; the realistic limiter is that a victim must load an attacker-supplied model, not network adjacency. Bottom line: a real but non-emergency priority - patch promptly because a trusted default mitigation is bypassed, but the absence of KEV/POC/EPSS suggests no widespread exploitation yet.

Exploit ScenarioDerived

An attacker publishes a trojanized .keras model (e.g. on a public model hub, or sends it directly to an ML engineer) whose StringLookup layer sets its vocabulary to a sensitive local path such as /etc/passwd or to an internal URL. When a victim loads it with keras.models.load_model - even with the default safe_mode=True - Keras reads that file (retrievable via get_vocabulary()) or fetches that endpoint via tf.io.gfile, yielding local file disclosure or attacker-directed internal requests (SSRF). No public exploit code was provided, but the linked GHSA advisory and PR #21751 test cases effectively demonstrate the mechanism.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Oct 19, 2026

Keras Model.load_model fails to enforce safe_mode=True for the StringLookup layer's vocabulary path handling, so a malicious .keras archive can cause arbitrary local file reads and server-side requests when a victim loads it. This CWE-502 deserialization-class flaw affects the Keras model-loading path and is assessed as confidentiality-focused, requiring user interaction to load the untrusted model; SSRF reach depends on the host's network access and available tf.io.gfile handlers. No public exploit was identified at time of analysis.

RemediationAI

Apply the upstream fix from PR #21751 and advisory GHSA-qg93-c7p6-gg7f; a specific released patched version was not independently confirmed in the provided data. Until a fixed release is confirmed, do not load .keras models from untrusted sources, and inspect archives for StringLookup or IndexLookup configurations where vocabulary is a string path or URI rather than an inline list or bundled asset. For trusted legacy models that require external vocabularies, pass safe_mode=False only after provenance validation and archive review, noting that this re-enables unsafe deserialization behavior. Alternatively, rebuild the archive with the vocabulary embedded as an asset or inline list. Restrict filesystem permissions and outbound network access on hosts that load models to limit local-file-read and SSRF impact, with the trade-off that legitimate GCS, HDFS, or HTTP vocabulary/asset loading may be disrupted.

Affected Packages

pypi keras fix: 3.12.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Keras .keras archives serialize layer configurations, and the StringLookup/IndexLookup preprocessing layer accepts a vocabulary argument that can be either an inline list or a string path/URI. During model loading, Keras uses tf.io.gfile to resolve file operations, which supports local paths and remote handlers such as GCS, HDFS, and HTTP/HTTPS; the fetched content is incorporated into model state and can be retrieved via get_vocabulary(). The safe_mode=True guard did not block this external vocabulary loading during deserialization, turning model loading into a local-file-read and SSRF primitive. The upstream fix in PR #21751 adds a serialization_lib.in_safe_mode() check in set_vocabulary and serializes external vocabularies as model assets while clearing the original path/URL. The root cause class is CWE-502 unsafe deserialization of attacker-controlled model configuration. The assessed CVSS 3.1 vector is AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N, with confidentiality impact only and no integrity or availability impact; no CPE data was supplied, but the affected code is in keras/src/layers/preprocessing/index_lookup.py and string_lookup handling.

Know when Keras gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (google) PRIMARY 5.9 MEDIUM
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
vuln.today AI 7.4 HIGH

Malicious models are network-distributed and load without special conditions (AV:N/AC:L/PR:N), but a victim must load the file (UI:R); file read plus SSRF reaches beyond the component (S:C) with arbitrary read (C:H) and no integrity or availability impact.

3.1 AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N
4.0 AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:N/VA:N/SC:L/SI:N/SA:N
Red Hat 5.5 MEDIUM

Primary rating from Vendor (google).

CVSS VectorVendor: google

Attack Vector
Adjacent
Attack Complexity
High
Attack Requirements
Present
Privileges Required
Low
User Interaction
Passive
Vulnerable system: Confidentiality
High
Vulnerable system: Integrity
Low
Vulnerable system: Availability
Low
Subsequent system: Confidentiality
High
Subsequent system: Integrity
Low
Subsequent system: Availability
Low

DescriptionCVE.org

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.

Threat Intelligence Overview

EPSS Score
0.2%
Top 85% exploitable
Prevalence
High
Keras is a very widely deployed deep-learning framework across ML/AI workloads
Data Quality
3 sources
Confidence: Low

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.2%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Controlled
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

30
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +30
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Server-Side Request Forgery exploits applications that fetch remote resources based on user-supplied URLs.

Insecure deserialization occurs when an application converts serialized data (a stream of bytes representing an object's state) back into a living object without proper validation.

More in Keras

View all
CVE-2025-9905 HIGH POC
7.3 Sep 19

The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True. Rated

CVE-2025-49655 CRITICAL
9.8 Oct 17

Deserialization of untrusted data in Keras 3.11.0 through 3.11.2 allows remote code execution when a victim loads a mali

CVE-2024-3660 CRITICAL
9.8 Apr 16

A arbitrary code injection vulnerability in TensorFlow's Keras framework (<2.13) allows attackers to execute arbitrary c

CVE-2025-12060 HIGH
8.9 Oct 30

Directory traversal in Keras through 3.11.3 allows an attacker who supplies a crafted tar archive to keras.utils.get_fil

CVE-2025-9906 HIGH
8.6 Sep 19

The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True. Rated

CVE-2026-11816 HIGH
8.1 Jun 11

Path traversal in Keras archive extraction utilities prior to version 3.14.0 allows remote attackers to write files outs

CVE-2026-0897 HIGH
7.1 Jan 15

Memory-exhaustion denial of service in Google Keras 3.0.0 through 3.13.0 lets a remote attacker crash the Python interpr

CVE-2026-1669 HIGH
7.1 Feb 11

Arbitrary local file disclosure in Keras 3.0.0 through 3.13.1 allows a remote attacker to read sensitive files from a vi

CVE-2025-8747 HIGH
8.6 Aug 11

A safe mode bypass vulnerability in the `Model.load_model` method in Keras versions 3.0.0 through 3.10.0 allows an attac

CVE-2024-55459 MEDIUM
6.5 Jan 08

An issue in keras 3.7.0 allows attackers to write arbitrary files to the user's machine via downloading a crafted tar fi

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy