Skip to content
RCE Disclosed report Advanced CVE-2026-12481

Keras: Lambda deserialization can bypass safe mode and execute code

The Lambda layer deserialization guard in Keras fails to block unsafe deserialization when safe_mode is None, which is the default outside a SafeModeScope. An attacker can supply a crafted config to execute arbitrary code via marshal bytecode.

keras-team/keras

Originally disclosed on huntr

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.

From the GitHub Advisory Database (GHSA-5gwj-m78q-7pq3, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code treats None (meaning 'not set') the same as False (meaning 'explicitly allowed'), so the safe-mode check is bypassed when safe_mode is None.

Impact

An attacker could achieve arbitrary OS-level code execution in the context of the server or user process.

What the attacker needed

Attacker can supply a crafted model config

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Keras is a machine learning library. When it loads a saved model, it can run code embedded in the model file. A safety check meant to stop this was skipped in a common default situation, so a malicious model file could run code on the victim's computer.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from keras-team/keras

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.