CVE-2025-9906: Keras Keras Is Vulnerable To Deserialization Vulnerability
HIGHCVE-2025-9906 is a HIGH (CVSS 7.3) keras is vulnerable to deserialization vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Keras libraries in the PyPI ecosystem. The issue involves keras is vulnerable to deserialization of untrusted data. Remediation is available by upgrading affected packages to version 3.11.0.
CVE-2025-9906 at a Glance
Security Impact
CVSS: 7.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2025-9906
To remediate this vulnerability, upgrade all affected Keras dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install keras>=3.11.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show keras
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-9906, inspect your installed packages using pip:
pip show keras
Analyze the terminal output to locate any version of Keras in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.11.0), your application is affected.
Note: The pip show keras command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Keras, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-9906 Affected Keras Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
keras
|
PyPI |
< 3.11.0
|
3.11.0
|
References
Frequently Asked Questions
What is CVE-2025-9906?
Which Keras versions are affected?
What version fixes CVE-2025-9906?
Is keras affected?
What is the CVSS score of CVE-2025-9906?
What CWE is associated with CVE-2025-9906?
How can I check PyPI dependencies for CVE-2025-9906?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-36fq-jgmw-4r9c",
"modified" : "2026-05-29T20:50:12Z",
"published" : "2025-09-19T09:31:14Z",
"aliases" : [ "CVE-2025-9906" ],
"summary" : "Keras is vulnerable to Deserialization of Untrusted Data",
"details" : "### Arbitrary Code Execution in Keras\n\nKeras versions prior to 3.11.0 allow for arbitrary code execution when loading a crafted `.keras` model archive, even when `safe_mode=True`.\n\nThe issue arises because the archive’s `config.json` is parsed before layer deserialization. This can invoke `keras.config.enable_unsafe_deserialization()`, effectively disabling safe mode from within the loading process itself. An attacker can place this call first in the archive and then include a `Lambda` layer whose function is deserialized from a pickle, leading to the execution of attacker-controlled Python code as soon as a victim loads the model file.\n\nExploitation requires a user to open an untrusted model; no additional privileges are needed. The fix in version 3.11.0 enforces safe-mode semantics *before* reading any user-controlled configuration and prevents the toggling of unsafe deserialization via the config file.\n\n**Affected versions:** < 3.11.0\n**Patched version:** 3.11.0\n\nIt is recommended to upgrade to version 3.11.0 or later and to avoid opening untrusted model files.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "keras"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.11.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-9906"
}, {
"type" : "WEB",
"url" : "https://github.com/keras-team/keras/pull/21429"
}, {
"type" : "WEB",
"url" : "https://github.com/keras-team/keras/commit/713172ab56b864e59e2aa79b1a51b0e728bba858"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/keras-team/keras"
}, {
"type" : "WEB",
"url" : "https://github.com/keras-team/keras/releases/tag/v3.11.0"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/keras/PYSEC-2025-76.yaml"
}, {
"type" : "WEB",
"url" : "https://osv.dev/vulnerability/CVE-2025-9906"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-502" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2025-09-19T17:16:44Z",
"nvd_published_at" : "2025-09-19T09:15:36Z"
}
}