CVE-2025-12058: Keras Keras Is Vulnerable To Arbitrary Vulnerability
MODERATECVE-2025-12058 is a MODERATE keras is vulnerable to arbitrary vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Keras libraries in the PyPI ecosystem. The issue involves keras is vulnerable to arbitrary local file loading and server-side request forgery. Remediation is available by upgrading affected packages to version 3.12.0.
CVE-2025-12058 at a Glance
How to Fix CVE-2025-12058
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.12.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-12058, 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.12.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-12058 Affected Keras Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
keras
|
PyPI |
< 3.12.0
|
3.12.0
|
References
Frequently Asked Questions
What is CVE-2025-12058?
Which Keras versions are affected?
What version fixes CVE-2025-12058?
Is keras affected?
What CWE is associated with CVE-2025-12058?
How can I check PyPI dependencies for CVE-2025-12058?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-mq84-hjqx-cwf2",
"modified" : "2025-10-29T16:04:40Z",
"published" : "2025-10-29T09:30:22Z",
"aliases" : [ "CVE-2025-12058" ],
"summary" : "Keras is vulnerable to arbitrary local file loading and Server-Side Request Forgery",
"details" : "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).\n\n\nThis 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.\n\n * 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.\n\n\n * 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.\n\n\nThe 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.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "keras"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.12.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/keras-team/keras/security/advisories/GHSA-qg93-c7p6-gg7f"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-12058"
}, {
"type" : "WEB",
"url" : "https://github.com/keras-team/keras/pull/21751"
}, {
"type" : "WEB",
"url" : "https://github.com/keras-team/keras/commit/61ac8c1e51862c471dee7b49029c356f55531487"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/keras-team/keras"
}, {
"type" : "WEB",
"url" : "https://www.cve.org/CVERecord?id=CVE-2025-12058"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-502", "CWE-918" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-10-29T16:04:40Z",
"nvd_published_at" : "2025-10-29T09:15:35Z"
}
}