Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. keras
  4. ›
  5. CVE-2025-9905

CVE-2025-9905: The Keras `Model.load_model` method **silently** ignores `safe_mode=True` and allows arbitrary code execution when a `.h5`/`.hdf5` file is loaded.

September 19, 2025

When a model in the .h5 (or .hdf5) format is loaded using the Keras Model.load_model method, the safe_mode=True setting is silently ignored without any warning or error. This allows an attacker to execute arbitrary code on the victim’s machine with the same privileges as the Keras application. This report is specific to the .h5/.hdf5 file format. The attack works regardless of the other parameters passed to load_model and does not require any sophisticated technique—.h5 and .hdf5 files are simply not checked for unsafe code execution.

From this point on, I will refer only to the .h5 file format, though everything equally applies to .hdf5.

References

  • github.com/advisories/GHSA-36rr-ww3j-vrjv
  • github.com/keras-team/keras
  • github.com/keras-team/keras/pull/21602
  • github.com/keras-team/keras/security/advisories/GHSA-36rr-ww3j-vrjv
  • nvd.nist.gov/vuln/detail/CVE-2025-9905

Code Behaviors & Features

Detect and mitigate CVE-2025-9905 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 3.0.0 before 3.11.3

Fixed versions

  • 3.11.3

Solution

Upgrade to version 3.11.3 or above.

Weakness

  • CWE-913: Improper Control of Dynamically-Managed Code Resources

Source file

pypi/keras/CVE-2025-9905.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sat, 20 Sep 2025 12:18:15 +0000.