CVE-2025-9905
Python vulnerability analysis and mitigation

Overview

The Keras Model.loadmodel method contains a critical vulnerability (CVE-2025-9905) that allows arbitrary code execution, even when safemode=True is enabled. The vulnerability affects the legacy .h5/.hdf5 model format in Keras 3, where a specially crafted model archive can trigger arbitrary code execution when loaded. The issue was discovered and disclosed on September 19, 2025, affecting Keras versions 3.0.0 to 3.11.2 (GitHub Advisory).

Technical details

The vulnerability stems from the fact that the safe_mode=True parameter is silently ignored when loading .h5/.hdf5 files in Keras. An attacker can craft a special .h5 archive file that uses the Lambda layer feature of Keras to embed arbitrary Python code in the form of pickled code. The vulnerability has been assigned a CVSS v4.0 score of 7.3 (High) with the vector string CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H. The issue is tracked as CWE-913 (Improper Control of Dynamically-Managed Code Resources) (NVD, GitHub Advisory).

Impact

When exploited, this vulnerability allows attackers to execute arbitrary code with the same privileges as the Keras application. The attack can be triggered simply by loading a malicious model file, requiring no further interaction. This makes it particularly dangerous in scenarios where models are shared or downloaded from untrusted sources, such as public model repositories or in federated learning environments (GitHub Advisory).

Mitigation and workarounds

The vulnerability has been patched in Keras version 3.11.3. Users are strongly advised to upgrade to this version or later. The .h5/.hdf5 format is considered legacy and is only supported for backwards compatibility in Keras 3. Users should consider migrating to the newer .keras format which properly implements the safe_mode security feature (GitHub Advisory).

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-6237CRITICAL9.8
  • PythonPython
  • invokeai
NoNoSep 18, 2025
CVE-2025-10157CRITICAL9.3
  • PythonPython
  • picklescan
NoYesSep 17, 2025
CVE-2025-10156CRITICAL9.3
  • PythonPython
  • picklescan
NoYesSep 17, 2025
CVE-2025-9906HIGH8.6
  • PythonPython
  • keras
NoYesSep 19, 2025
CVE-2025-9905HIGH7.3
  • PythonPython
  • keras
NoYesSep 19, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management