Skip to main content

Keras CVE-2025-49655

CRITICAL
Deserialization of Untrusted Data (CWE-502)
2025-10-17 6f8de1f0-f67e-45a6-b68f-98777fdb759c GHSA-cvhh-q5g5-qprp
9.8
CVSS 3.1 · Vendor: 6f8de1f0-f67e-45a6-b68f-98777fdb759c
View

Attack ChainAIDerived

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

  1. Access
    Craft malicious .keras file with TorchModuleWrapper
  2. Exploit
    Victim loads model via load_model()
  3. Execution
    torch.load() runs despite safe mode
  4. Impact
    Arbitrary code executes on victim host

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 the victim to load an attacker-supplied Keras model file (local or remote URL) containing a TorchModuleWrapper class, which triggers torch.load() during from_config() deserialization in Keras 3.11.0, 3.11.1, or 3.11.2. The defining condition is that this path executes even with safe_mode ENABLED (the default), so the usual safeguard does not stop it. Limiting factors: the attack needs the victim to obtain and deliberately load the malicious .keras file (user interaction), and only the narrow version band 3.11.0-3.11.2 is affected - 3.11.3 and later raise a ValueError in safe mode, and earlier branches are unaffected.

Impact

The input CVSS of 9.8 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H) rates this CRITICAL, and CWE-502 deserialization leading to RCE is a genuinely dangerous class. However, the signals partially conflict: the NVD vector marks UI:N, yet the description states the code only runs 'when loaded' - i.e. a victim must actively load an attacker-supplied Keras model file - which is user interaction and materially lowers real-world likelihood versus a true no-interaction network RCE. No EPSS score was provided in the input, so exploitation probability cannot be quantified here. The CVE is NOT listed in CISA KEV and no public exploit was flagged in the input, so there is no confirmation of active exploitation; the referenced HiddenLayer security advisory indicates researcher attention but is not a POC signal. The most security-relevant fact is that exploitation bypasses Keras safe_mode, the DEFAULT protection users rely on - this elevates priority for anyone loading untrusted .keras files. Net assessment: a real, high-priority issue for ML pipelines that ingest third-party models, but the required user interaction and narrow affected range (3.11.0-3.11.2) make it closer to a targeted/social-engineering vector than mass-exploitable network RCE. The UI:N in the NVD vector should be verified with the vendor, as it likely overstates the no-interaction nature of the flaw.

Exploit ScenarioDerived

An attacker publishes a trojanized model to a model hub or sends it directly, embedding a TorchModuleWrapper that invokes torch.load(). When a victim loads the file with Keras 3.11.0-3.11.2 using keras.saving.load_model() - even with safe_mode enabled - the malicious payload deserializes and executes arbitrary code on the victim's host. No public exploit was identified in the input, though a HiddenLayer advisory describes the issue.

Act Now Prioritize within 24-48h. Why: CRITICAL severity.
Patch available 0.8% exploitation probability (EPSS)

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

Alert me

AnalysisAIv1 – Oct 19, 2026

Deserialization of untrusted data in Keras 3.11.0 through 3.11.2 allows remote code execution when a victim loads a maliciously crafted Keras model file containing a TorchModuleWrapper, even with safe mode enabled (the default). The bypass occurs because torch.load() is invoked during from_config() deserialization without the safe-mode check; exploitation requires user interaction to load the file, which can be local or fetched from a remote URL. No public exploit code or confirmed active exploitation was identified at time of analysis, but the unauthenticated network vector and high impact make this critical.

RemediationAI

Upgrade to Keras 3.11.3 or later, which enforces the safe-mode check and raises a ValueError when a TorchModuleWrapper is encountered during safe-mode deserialization (vendor-released patch: 3.11.3). If immediate upgrade is not possible, treat all .keras files as untrusted: do not load models from untrusted sources, and restrict model loading to vetted, internally produced artifacts. Because safe_mode is bypassed in affected versions, there is no configuration-only fix; disabling or avoiding TorchModuleWrapper in model files and blocking untrusted model downloads at the network/proxy layer are compensating controls, but they trade functionality for risk reduction. See the advisory at https://hiddenlayer.com/sai_security_advisor/2025-10-keras/ and the fix PR at https://github.com/keras-team/keras/pull/21575.

Affected Packages

pypi keras fix: 3.11.3

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 is a deep learning framework that serializes model architectures and weights into .keras files. The TorchModuleWrapper class in keras/src/utils/torch_utils.py wraps a PyTorch nn.Module and implements from_config(); prior to the fix, this method called torch.load() on attacker-controlled data without checking Keras's safe_mode flag. This is a CWE-502 deserialization flaw: loading a malicious .keras file causes arbitrary code execution via PyTorch's pickle-based deserialization. The fix in PR 21575 adds an in_safe_mode() check that raises a ValueError by default, requiring explicit opt-in (safe_mode=False or keras.config.enable_unsafe_deserialization()) to load torch.nn.Module objects. Affected versions are 3.11.0, 3.11.1, and 3.11.2; 3.11.3 and later include the guard.

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 (6f8de1f0-f67e-45a6-b68f-98777fdb759c) PRIMARY 9.8 CRITICAL
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
vuln.today AI 8.8 HIGH

Code runs only when a victim loads the attacker-supplied model, so UI:R rather than NVD's UI:N; remote/local file delivery keeps AV:N, AC:L and full C/I/A impact from arbitrary code execution.

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

Primary rating from Vendor (6f8de1f0-f67e-45a6-b68f-98777fdb759c).

CVSS VectorVendor: 6f8de1f0-f67e-45a6-b68f-98777fdb759c

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

DescriptionCVE.org

Deserialization of untrusted data can occur in versions of the Keras framework running versions 3.11.0 up to but not including 3.11.3, enabling a maliciously uploaded Keras file containing a TorchModuleWrapper class to run arbitrary code on an end user’s system when loaded despite safe mode being enabled. The vulnerability can be triggered through both local and remote files.

Executive ViewAI

Why It Matters

A critical deserialization flaw in Keras versions 3.11.0 through 3.11.2 allows a booby-trapped model file to run attacker code on any machine that loads it, and it defeats the library's default safe-mode protection. The exposure is concentrated in data science, MLOps, and research teams that routinely download or exchange pretrained models, where a single malicious file could hand an intruder control of a developer workstation or a build/inference server. Leadership should care because model artifacts are shared with far less scrutiny than software packages, the flaw cannot be fixed by configuration alone, and no vendor patch exists yet.

Business Impact: High
Compensating Controls

No vendor-released patch identified at time of analysis; interim mitigations are to downgrade to Keras 3.10.x or earlier, refuse to load model files from untrusted or unverified sources, verify hashes or signatures on all model artifacts before loading, run model-loading workloads in sandboxed low-privilege containers or VMs with restricted egress and no access to production secrets, and block or closely monitor use of TorchModuleWrapper in inbound model files.

Threat Intelligence Overview

EPSS Score
0.8%
Top 46% exploitable
Prevalence
High
Keras is a widely deployed deep-learning framework with a large ML footprint
Threat Intel
1
1 source
Data Quality
3 sources
Confidence: Low
NVD CVE.org EPSS GHSA Vendor GitHub

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 CRITICAL
CISA KEV No
Public POC No
EPSS 0.8%
Patch available Yes
Active threat No
Deciding rule
CRITICAL severity
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
Open
Automatable· derived
Yes
Human Impact
High

Priority Score

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

Attack Technique

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.

Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.

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-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-12058 MEDIUM
5.9 Oct 29

Keras Model.load_model fails to enforce safe_mode=True for the StringLookup layer's vocabulary path handling, so a malic

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