Junglewise Threat Intelligence

CVE-2025-9906: Keras arbitrary code execution via untrusted model deserialization

CVE-2025-9906 · Severity: high · CVSS 7.3 · Published 2025-09-19

Executive brief

Keras, a popular deep learning library, is vulnerable to a security flaw that allows for arbitrary code execution when loading a specially crafted model file. Even if 'safe mode' is enabled, a malicious model can bypass these protections and run unauthorized commands on the user's system. This could lead to a complete system compromise or data theft if a user is tricked into opening an untrusted model file.

Technical details

A deserialization vulnerability exists in Keras versions prior to 3.11.0 due to the order in which model archives are processed. The archive's 'config.json' is parsed before layer deserialization, allowing a crafted configuration to invoke 'keras.config.enable_unsafe_deserialization()', which disables safe mode. An attacker can then include a 'Lambda' layer with a pickled function that executes arbitrary Python code upon loading. This bypasses the 'safe_mode=True' setting. The vulnerability is addressed in version 3.11.0 by enforcing safe-mode semantics before reading user-controlled configurations.

Affected products

  • Keras Team Keras < 3.11.0

Timeline

  • 2025-09-19: disclosed: Vulnerability disclosed and CVE-2025-9906 assigned.
  • 2025-09-19: advisory: GitHub Advisory GHSA-36fq-jgmw-4r9c published.
  • 2025-09-19: patched: Fixed in Keras version 3.11.0.

References

Related threats