Skip to content
KerasGHSA-5gwj-m78q-7pq3

Keras: Lambda deserialization can bypass safe mode and execute code

High8.8CVE-2026-12481 · Published Jul 3, 2026 · updated Aug 10, 2026

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.

GitHub advisory

Affected versions

PackageAffectedFixed in
keras
PyPI
< 3.12.33.12.3
>= 3.13.0, < 3.15.03.15.0
Details and references

More Keras advisories

All Keras
Advisory
Keras: HDF5 links can disclose local file contents
Medium6.5Aug 2
Keras: TorchModuleWrapper can deserialize unsafe PyTorch pickle data
High7.8Jul 19
Keras: tar extraction permits symlink-based path traversal
Low3.1Jul 14
Keras: HDF5 virtual datasets can disclose local files
Medium5.5Jul 1
Keras: DiskIOStore permits path traversal through crafted layer names
Medium6.1Jun 22
Keras archive extraction utilities allow path traversal and arbitrary file writes
High8.1Jun 11

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.