CVE-2025-12058: Vulnerability in Keras Model.load_model Leading to Arbitrary Local File Loading and SSRF

Published Oct 29, 2025
·
Updated

The Keras.Model.loadmodel method, including when executed with the intended security mitigation safemode=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 getvocabulary()), 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 safemode=True flag, which was intended to prevent such unintended data access.

Other sources

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

Microsoft

Affected Software

5 affected componentsFixes available
Keras Keras
pip/keras<3.12.0
3.12.0
Microsoft azl3 keras 3.3.3-4
Microsoft cbl2 keras 2.11.0-3
Microsoft azl3 keras 3.3.3-5

Event History

Oct 29, 2025
CVE Published
via MITRE·08:48 AM
Data Sourced
via MITRE·08:48 AM
DescriptionWeakness
Data Sourced
via NVD·09:15 AM
DescriptionSeverityWeakness
Advisory Published
via GitHub·09:30 AM
Data Sourced
via GitHub·09:30 AM
DescriptionWeaknessAffected Software
Oct 31, 2025
Data Sourced
via Microsoft·01:03 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·01:03 AM
Affected Software
Updated
via Microsoft·01:03 AM
DescriptionSeverity
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-12058?

CVE-2025-12058 is classified as a high severity vulnerability due to its potential for arbitrary local file loading and Server-Side Request Forgery.

2

How do I fix CVE-2025-12058?

To mitigate CVE-2025-12058, ensure you update to the latest version of Keras where this vulnerability has been addressed.

3

What is affected by CVE-2025-12058?

CVE-2025-12058 affects the Keras.Model.load_model method, specifically when the StringLookup layer is involved.

4

Can CVE-2025-12058 lead to data leakage?

Yes, CVE-2025-12058 can lead to data leakage because it allows arbitrary file access on the server.

5

Is safe_mode=True sufficient to mitigate CVE-2025-12058?

No, even with safe_mode=True, CVE-2025-12058 remains vulnerable, so an update or further mitigation is necessary.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203