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

CVE-2025-9906: Keras is vulnerable to Deserialization of Untrusted Data

September 19, 2025

The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True.

One can create a specially crafted .keras model archive that, when loaded via Model.load_model, will trigger arbitrary code to be executed. This is achieved by crafting a special config.json (a file within the .keras archive) that will invoke keras.config.enable_unsafe_deserialization() to disable safe mode. Once safe mode is disable, one can use the Lambda layer feature of keras, which allows arbitrary Python code in the form of pickled code. Both can appear in the same archive. Simply the keras.config.enable_unsafe_deserialization() needs to appear first in the archive and the Lambda with arbitrary code needs to be second.

References

  • github.com/advisories/GHSA-36fq-jgmw-4r9c
  • github.com/keras-team/keras
  • github.com/keras-team/keras/commit/713172ab56b864e59e2aa79b1a51b0e728bba858
  • github.com/keras-team/keras/pull/21429
  • nvd.nist.gov/vuln/detail/CVE-2025-9906

Code Behaviors & Features

Detect and mitigate CVE-2025-9906 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 before 3.11.0

Fixed versions

  • 3.11.0

Solution

Upgrade to version 3.11.0 or above.

Weakness

  • CWE-502: Deserialization of Untrusted Data

Source file

pypi/keras/CVE-2025-9906.yml

Spotted a mistake? Edit the file on GitLab.

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

Page generated Sat, 20 Sep 2025 00:20:00 +0000.