CVE-2026-12481: Keras: safe_mode=None bypass enables Lambda RCE
GHSA-5gwj-m78q-7pq3 CRITICAL CISA: ATTENDKeras 3.14.0 contains a logic flaw in its Lambda layer deserialization guard: the safety check treats `safe_mode=None` (the default when `from_config()` is called outside a `SafeModeScope`) as if it were explicitly disabled, allowing attacker-controlled marshal bytecode to execute arbitrary OS commands during model load. This matters because Keras sits at the base of countless model-serving, fine-tuning, and notebook pipelines, and any code path that calls `keras.layers.deserialize()`, `keras.models.clone_model()`, or `Lambda.from_config()` without wrapping it in `SafeModeScope(True)` is silently exposed by default, not by misconfiguration. There is no CISA KEV listing, no public exploit, and no Nuclei template yet, and EPSS sits at 0.4% (top 68th percentile) — so this looks pre-weaponization rather than actively exploited, but the vulnerability class (unsafe pickle/marshal-style deserialization in ML model loading) has a long track record of rapid PoC turnaround once details circulate via the huntr bounty writeup. Upgrade past the affected 3.14.0 release as soon as a patched Keras version is available, and in the interim explicitly enforce `SafeModeScope(True)` (or `safe_mode=True`) around every `from_config`/`deserialize`/`clone_model` call and treat any model file from an untrusted source as executable code, not data.
What is the risk?
Moderate-to-high latent severity, currently low observed exploitation. The flaw grants arbitrary OS-level code execution — the worst-case outcome for a deserialization bug — but exploitation requires an attacker to supply a crafted model/config that gets loaded through an unguarded Keras deserialization path, which typically means either a malicious model file (supply chain) or an application that loads user-supplied models/configs. No CVSS score is published yet, EPSS is low (0.4%, 68th percentile), it is not in CISA KEV, and there is no public exploit or Nuclei template. The real risk driver is Keras's ubiquity as a foundational ML library: any organization loading third-party or user-supplied `.keras`/`.h5` models or configs without an explicit safe-mode wrapper is exposed by default, making this a supply-chain-adjacent risk rather than a directly internet-facing one.
How does the attack unfold?
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| Keras | pip | < 3.12.3 | 3.12.3 |
Do you use Keras? You're affected.
How severe is it?
What is the attack surface?
What should I do?
1 step-
1) Upgrade Keras past 3.14.0 once a patched release addressing
_raise_for_lambda_deserialization()is available — track the huntr advisory and keras-team release notes. 2) Until patched, explicitly wrap everykeras.layers.deserialize(),keras.models.clone_model(), andLambda.from_config()call inwith keras.saving.SafeModeScope(True):rather than relying on the default. 3) Never load Keras models or configs from untrusted or unauthenticated sources (user uploads, public model hubs, third-party partners) without this guard. 4) Detection: audit codebases forfrom_config(,clone_model(, andlayers.deserialize(call sites lacking an enclosingSafeModeScope; add a static-analysis or CI grep rule to catch regressions. 5) Where feasible, run model-loading services in a sandboxed/least-privilege container so that even successful marshal bytecode execution has minimal blast radius.
What does CISA's SSVC say?
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2026-12481?
Keras 3.14.0 contains a logic flaw in its Lambda layer deserialization guard: the safety check treats `safe_mode=None` (the default when `from_config()` is called outside a `SafeModeScope`) as if it were explicitly disabled, allowing attacker-controlled marshal bytecode to execute arbitrary OS commands during model load. This matters because Keras sits at the base of countless model-serving, fine-tuning, and notebook pipelines, and any code path that calls `keras.layers.deserialize()`, `keras.models.clone_model()`, or `Lambda.from_config()` without wrapping it in `SafeModeScope(True)` is silently exposed by default, not by misconfiguration. There is no CISA KEV listing, no public exploit, and no Nuclei template yet, and EPSS sits at 0.4% (top 68th percentile) — so this looks pre-weaponization rather than actively exploited, but the vulnerability class (unsafe pickle/marshal-style deserialization in ML model loading) has a long track record of rapid PoC turnaround once details circulate via the huntr bounty writeup. Upgrade past the affected 3.14.0 release as soon as a patched Keras version is available, and in the interim explicitly enforce `SafeModeScope(True)` (or `safe_mode=True`) around every `from_config`/`deserialize`/`clone_model` call and treat any model file from an untrusted source as executable code, not data.
Is CVE-2026-12481 actively exploited?
No confirmed active exploitation of CVE-2026-12481 has been reported, but organizations should still patch proactively.
How to fix CVE-2026-12481?
1) Upgrade Keras past 3.14.0 once a patched release addressing `_raise_for_lambda_deserialization()` is available — track the huntr advisory and keras-team release notes. 2) Until patched, explicitly wrap every `keras.layers.deserialize()`, `keras.models.clone_model()`, and `Lambda.from_config()` call in `with keras.saving.SafeModeScope(True):` rather than relying on the default. 3) Never load Keras models or configs from untrusted or unauthenticated sources (user uploads, public model hubs, third-party partners) without this guard. 4) Detection: audit codebases for `from_config(`, `clone_model(`, and `layers.deserialize(` call sites lacking an enclosing `SafeModeScope`; add a static-analysis or CI grep rule to catch regressions. 5) Where feasible, run model-loading services in a sandboxed/least-privilege container so that even successful marshal bytecode execution has minimal blast radius.
What systems are affected by CVE-2026-12481?
This vulnerability affects the following AI/ML architecture patterns: model serving, training pipelines, ml-ops platforms, notebook/research environments.
What is the CVSS score for CVE-2026-12481?
CVE-2026-12481 has a CVSS v3.1 base score of 9.8 (CRITICAL). The EPSS exploitation probability is 0.47%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0010.001 AI Software AML.T0011.000 Unsafe AI Artifacts AML.T0018.002 Embed Malware AML.T0050 Command and Scripting Interpreter Compliance Controls Affected
What are the technical details?
Original Advisory
A vulnerability in keras-team/keras version 3.14.0 allows for arbitrary code execution due to improper handling of deserialization in the `Lambda` layer. Specifically, the `_raise_for_lambda_deserialization()` function fails to enforce the safe-mode guard when `safe_mode` is set to `None`, which is the default value when `from_config()` is called outside of a `SafeModeScope` context. This logic error conflates `None` (unset/default-deny) with `False` (explicitly disabled), bypassing the guard and allowing attacker-controlled `marshal` bytecode to be deserialized. Affected call sites include `keras.layers.deserialize(config)`, `keras.models.clone_model(model)`, and any direct invocation of `Lambda.from_config(config)` without an enclosing `SafeModeScope(True)`. This vulnerability can be exploited to achieve arbitrary OS-level code execution in the context of the server or user process.
Exploitation Scenario
An attacker crafts a malicious `.keras` model file (or a bare model config) containing a `Lambda` layer whose serialized function is Python `marshal` bytecode that executes an OS command on load — e.g., a reverse shell or credential-harvesting payload. The attacker distributes this file via a public model-sharing platform, a pull request to an ML repo, or directly to a victim organization's model upload/inference endpoint, disguised as a legitimate fine-tuned model. When the victim's application calls `keras.models.clone_model()` or `keras.layers.deserialize()` on the file without wrapping it in `SafeModeScope(True)` — the default, unguarded behavior — the marshal bytecode executes with the privileges of the loading process, giving the attacker code execution on the model-serving host or the data scientist's workstation.
Weaknesses (CWE)
CWE-502 Deserialization of Untrusted Data
Primary
CWE-502 Deserialization of Untrusted Data
Primary
CWE-502 Deserialization of Untrusted Data CWE-502 — Deserialization of Untrusted Data: The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.
- [Architecture and Design, Implementation] If available, use the signing/sealing features of the programming language to assure that deserialized data has not been tainted. For example, a hash-based message authentication code (HMAC) could be used to ensure that data has not been modified.
- [Implementation] When deserializing data, populate a new object rather than just deserializing. The result is that the data flows through safe input validation and that the functions are safe.
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H References
- github.com/advisories/GHSA-5gwj-m78q-7pq3
- github.com/keras-team/keras/commit/55888d3becbdbb45dc16a55b489900f911e2dde5
- github.com/keras-team/keras/commit/d338a45204bdc787c8b3c4a9b82c1911cd52dedf
- github.com/keras-team/keras/pull/23048
- github.com/keras-team/keras/pull/23165
- github.com/keras-team/keras/releases/tag/v3.12.3
- github.com/keras-team/keras/releases/tag/v3.15.0
- nvd.nist.gov/vuln/detail/CVE-2026-12481
- huntr.com/bounties/59ceaed1-c8a3-4135-8f94-169ade02823d
Timeline
Related Vulnerabilities
CVE-2025-49655 9.8 keras: Deserialization enables RCE
Same package: keras CVE-2025-1550 9.8 Keras: safe_mode bypass enables RCE via model loading
Same package: keras CVE-2024-3660 9.8 Keras: RCE via malicious model deserialization
Same package: keras CVE-2024-49326 9.8 Affiliator WP Plugin: Unauthenticated Web Shell Upload
Same package: keras CVE-2025-12060 9.8 keras: Path Traversal enables file access
Same package: keras