CVE-2025-12058
JSON

5.9medium

Vulnerability in Keras Model.load_model Leading to Arbitrary Local File Loading and SSRF

Severity
5.9medium CVSS:4.0 by Google
Exploit likelihood
0.25% (higher than 18% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
Google
Also known as
GHSA-mq84-hjqx-cwf2GHSA-qg93-c7p6-gg7fPYSEC-2026-1487

Description

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.

Affected

Product or packageVersionsReported by
Keras Kerasbefore 3.12.0CVE List
keras (PyPI)before 3.12.0GitHub Advisory Database, PyPA Advisory Database

All scores

Google5.9medium CVSS:4.0CVSS:4.0/AV:A/AC:H/AT:P/PR:L/UI:P/VC:H/VI:L/VA:L/SC:H/SI:L/SA:L
GitHubmedium CVSS:4.0CVSS: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
PyPA Advisory DatabaseNot scored CVSS:4.0CVSS: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

Classification

CWE-502CWE-918

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

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.

NVD (es)

El método Keras.Model.load_model, incluso cuando se ejecuta con la mitigación de seguridad prevista safe_mode=True, es vulnerable a la carga arbitraria de archivos locales y a la falsificación de petición del lado del servidor (SSRF). Esta vulnerabilidad se deriva de la forma en que se maneja la capa StringLookup durante la carga del modelo desde un archivo .keras especialmente diseñado. El constructor de la capa StringLookup acepta un argumento vocabulary que puede especificar una ruta de archivo local o una ruta de archivo remota. * Lectura Arbitraria de Archivos Locales: Un atacante puede crear un archivo .keras malicioso que incrusta una ruta local en la configuración de la capa StringLookup. Cuando se carga el modelo, Keras intentará leer el contenido del archivo local especificado e incorporarlo al estado del modelo (por ejemplo, recuperable a través de get_vocabulary()), permitiendo a un atacante leer archivos locales arbitrarios en el sistema anfitrión. * Falsificación de Petición del Lado del Servidor (SSRF): Keras utiliza tf.io.gfile para operaciones de archivos. Dado que tf.io.gfile soporta manejadores de sistemas de archivos remotos (como GCS y HDFS) y protocolos HTTP/HTTPS, el mismo mecanismo puede ser aprovechado para obtener contenido de puntos finales de red arbitrarios en nombre del servidor, lo que resulta en una condición de SSRF. El problema de seguridad es que la característica que permite la carga de rutas externas no fue restringida adecuadamente por el indicador safe_mode=True, el cual estaba destinado a prevenir dicho acceso no intencionado a los datos.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-12058 changed 2025-10-29CVE Terms of Use
GitHub Advisory DatabaseGHSA-mq84-hjqx-cwf2 changed 2026-09-10CC-BY-4.0
NVDCVE-2025-12058 changed 2026-10-19Public domain
PyPA Advisory DatabasePYSEC-2026-1487 changed 2026-07-07CC-BY-4.0