Keras is vulnerable to Deserialization of Untrusted Data
High7.3CVE-2025-9906 · Published Sep 19, 2025 · updated Sep 10, 2026
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| keras PyPI | < 3.11.0 | 3.11.0 |
Details and references
### Arbitrary Code Execution in Keras Keras versions prior to 3.11.0 allow for arbitrary code execution when loading a crafted `.keras` model archive, even when `safe_mode=True`. The issue arises because the archive’s `config.json` is parsed before layer deserialization. This can invoke `keras.config.enable_unsafe_deserialization()`, effectively disabling safe mode from within the loading process itself. An attacker can place this call first in the archive and then include a `Lambda` layer whose function is deserialized from a pickle, leading to the execution of attacker-controlled Python code as soon as a victim loads the model file. Exploitation requires a user to open an untrusted model; no additional privileges are needed. The fix in version 3.11.0 enforces safe-mode semantics *before* reading any user-controlled configuration and prevents the toggling of unsafe deserialization via the config file. **Affected versions:** < 3.11.0 **Patched version:** 3.11.0 It is recommended to upgrade to version 3.11.0 or later and to avoid opening untrusted model files.
- CVSS 3.1
- CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-502
- Also known as
- CVE-2025-9906, PYSEC-2025-76
- nvd.nist.gov/vuln/detail/CVE-2025-9906
- github.com/keras-team/keras/pull/21429
- github.com/keras-team/keras/commit/713172ab56b864e59e2aa79b1a51b0e728bba858
- github.com/keras-team/keras
- github.com/keras-team/keras/releases/tag/v3.11.0
- github.com/pypa/advisory-database/tree/main/vulns/keras/PYSEC-2025-76.yaml
- osv.dev/vulnerability/CVE-2025-9906
More Keras advisories
All Keras| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Sep 192025 | The Keras `Model.load_model` method **silently** ignores `safe_mode=True` and allows arbitrary code execution when a `.h5`/`.hdf5` file is loaded. CVE-2025-9905Highfixed in 3.11.3 | High | 3.11.3 |
| Oct 172025 | Keras framework vulnerable to deserialization of untrusted data CVE-2025-49655Critical9.8fixed in 3.11.3 | Critical9.8 | 3.11.3 |
| Aug 122025 | Keras vulnerable to CVE-2025-1550 bypass via reuse of internal functionality CVE-2025-8747High8.8fixed in 3.11.0 | High8.8 | 3.11.0 |
| Oct 292025 | Keras is vulnerable to arbitrary local file loading and Server-Side Request Forgery CVE-2025-12058Mediumfixed in 3.12.0 | Medium | 3.12.0 |
| Dec 22025 | Keras Directory Traversal Vulnerability CVE-2025-12060High9.8fixed in 3.12.0 | High9.8 | 3.12.0 |
| Feb 18 | Keras has a Local File Disclosure via HDF5 External Storage During Keras Weight Loading CVE-2026-1669High7.1fixed in 3.12.1, 3.13.2 | High7.1 | 3.12.1, 3.13.2 |