id: PYSEC-2026-1487 published: "2026-07-07T16:03:08.498075Z" modified: "2026-07-07T17:24:23.652640Z" aliases: - CVE-2025-12058 - GHSA-mq84-hjqx-cwf2 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." affected: - package: name: keras ecosystem: PyPI purl: pkg:pypi/keras ranges: - type: ECOSYSTEM events: - introduced: "0" - fixed: 3.12.0 versions: - 0.2.0 - 0.3.0 - 0.3.1 - 0.3.2 - 0.3.3 - 1.0.0 - 1.0.1 - 1.0.2 - 1.0.3 - 1.0.4 - 1.0.5 - 1.0.6 - 1.0.7 - 1.0.8 - 1.1.0 - 1.1.1 - 1.1.2 - 1.2.0 - 1.2.1 - 1.2.2 - 2.0.0 - 2.0.1 - 2.0.2 - 2.0.3 - 2.0.4 - 2.0.5 - 2.0.6 - 2.0.7 - 2.0.8 - 2.0.9 - 2.1.0 - 2.1.1 - 2.1.2 - 2.1.3 - 2.1.4 - 2.1.5 - 2.1.6 - 2.10.0 - 2.10.0rc0 - 2.10.0rc1 - 2.11.0 - 2.11.0rc0 - 2.11.0rc1 - 2.11.0rc2 - 2.11.0rc3 - 2.12.0 - 2.12.0rc0 - 2.12.0rc1 - 2.13.1 - 2.13.1rc0 - 2.13.1rc1 - 2.14.0 - 2.14.0rc0 - 2.15.0 - 2.15.0rc0 - 2.15.0rc1 - 2.2.0 - 2.2.1 - 2.2.2 - 2.2.3 - 2.2.4 - 2.2.5 - 2.3.0 - 2.3.1 - 2.4.0 - 2.4.1 - 2.4.2 - 2.4.3 - 2.5.0rc0 - 2.6.0 - 2.6.0rc0 - 2.6.0rc1 - 2.6.0rc2 - 2.6.0rc3 - 2.7.0 - 2.7.0rc0 - 2.7.0rc2 - 2.8.0 - 2.8.0rc0 - 2.8.0rc1 - 2.9.0 - 2.9.0rc0 - 2.9.0rc1 - 2.9.0rc2 - 3.0.0 - 3.0.1 - 3.0.2 - 3.0.3 - 3.0.4 - 3.0.5 - 3.1.0 - 3.1.1 - 3.10.0 - 3.11.0 - 3.11.1 - 3.11.2 - 3.11.3 - 3.2.0 - 3.2.1 - 3.3.0 - 3.3.1 - 3.3.2 - 3.3.3 - 3.4.0 - 3.4.1 - 3.5.0 - 3.6.0 - 3.7.0 - 3.8.0 - 3.9.0 - 3.9.1 - 3.9.2 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 - type: PACKAGE url: https://pypi.org/project/keras - type: ADVISORY url: https://github.com/advisories/GHSA-mq84-hjqx-cwf2 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