# CVE-2026-12481: Keras Team Keras arbitrary code execution in Lambda layer

Source: https://junglewise.ai/threats/cve-2026-12481-keras-team-keras-arbitrary-code-execution-in-lambda-layer  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-07-03. Updated: 2026-08-07  
License: CC BY 4.0 with a link back

CVE-2026-12481 · Severity: high · CVSS 8.8 · Published 2026-07-03

Keras, a popular machine learning library, contains a vulnerability that could allow an attacker to execute malicious code on a user's system. The issue exists in how the library handles certain model components (Lambda layers) during the loading process, failing to properly enforce security restrictions. If a user is tricked into loading a specially crafted malicious model file, an attacker could gain full control over the underlying server or workstation.

Technologies: [keras (PyPI)](https://junglewise.ai/threats/technologies/keras). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2026-12481 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-12481 being exploited in the wild.

**How severe is CVE-2026-12481?** High severity, with a CVSS score of 8.8, published 3 July 2026.

**Which products and versions are affected?** keras (PyPI) ECOSYSTEM:introduced=0,fixed=3.12.3, ECOSYSTEM:introduced=0,fixed=3.12.3,introduced=3.13.0,fixed=3.15.0.

**Is there a fix for CVE-2026-12481?** Yes. keras (PyPI): upgrade to 3.12.3, 3.15.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-12481 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-12481?** Check whether you run keras (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- keras (PyPI): upgrade to 3.12.3, 3.15.0 or later

  ```sh
  pip install "keras>=3.15.0"
  ```


## Technical details

A logic error in the `_raise_for_lambda_deserialization()` function and `TorchModuleWrapper.from_config()` fails to enforce safe-mode guards when `safe_mode` is set to `None` (the default state outside of a `SafeModeScope`). The library conflates this `None` value with `False`, allowing the deserialization of attacker-controlled `marshal` bytecode or `torch.load()` pickles. Attackers can exploit this by providing a malicious configuration to call sites such as `keras.layers.deserialize()`, `keras.models.clone_model()`, or direct `Lambda.from_config()` calls. Successful exploitation results in arbitrary OS-level code execution in the context of the process. The issue is patched in versions 3.12.3 and 3.15.0 by ensuring the library fails closed when safe mode is unset.

## Affected products

- Keras Team Keras < 3.12.3, >= 3.13.0, < 3.15.0

## Identifiers

- CVE-2026-12481
- GHSA-5gwj-m78q-7pq3
- PYSEC-2026-3631

## Timeline

- 2026-06-06: patched: Initial fix submitted via PR 23048
- 2026-07-03: disclosed: Vulnerability disclosed and CVE-2026-12481 assigned
- 2026-07-03: advisory: GitHub Advisory published

## References

- [https://huntr.com/bounties/59ceaed1-c8a3-4135-8f94-169ade02823d](https://huntr.com/bounties/59ceaed1-c8a3-4135-8f94-169ade02823d)
- [https://github.com/keras-team/keras/pull/23048](https://github.com/keras-team/keras/pull/23048)
- [https://github.com/keras-team/keras/pull/23165](https://github.com/keras-team/keras/pull/23165)
- [https://github.com/keras-team/keras/commit/55888d3becbdbb45dc16a55b489900f911e2dde5](https://github.com/keras-team/keras/commit/55888d3becbdbb45dc16a55b489900f911e2dde5)
- [https://github.com/keras-team/keras/commit/d338a45204bdc787c8b3c4a9b82c1911cd52dedf](https://github.com/keras-team/keras/commit/d338a45204bdc787c8b3c4a9b82c1911cd52dedf)

## Related threats

- [Keras model loading denial of service via HDF5 shape bombs](https://junglewise.ai/threats/cve-2026-12570-keras-model-loading-denial-of-service-via-hdf5-shape-bombs)
- [Keras HDF5 arbitrary file disclosure via ExternalLinks](https://junglewise.ai/threats/cve-2026-9335-keras-hdf5-arbitrary-file-disclosure-via-externallinks)
- [Keras unsafe deserialization in TorchModuleWrapper](https://junglewise.ai/threats/cve-2026-12484-keras-unsafe-deserialization-in-torchmodulewrapper)
- [Keras path traversal via symlink in filter_safe_tarinfos](https://junglewise.ai/threats/cve-2026-12482-keras-path-traversal-via-symlink-in-filter-safe-tarinfos)
- [Keras arbitrary HDF5 file read in model loading](https://junglewise.ai/threats/cve-2026-12480-keras-arbitrary-hdf5-file-read-in-model-loading)
