GHSA-5gwj-m78q-7pq3 is a high-severity (CVSS 8.8) Deserialization of Untrusted Data vulnerability in keras. A fix is available for keras — see the affected versions and patch details below.
Keras: Lambda deserialization can bypass safe mode and execute code
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- A successful exploit gives an attacker total control of the affected component, not partial access.
Exploitation and automatability from CISA’s SSVC triage for GHSA-5gwj-m78q-7pq3.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
GHSA-5gwj-m78q-7pq3 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 381,682 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
keras🐍kerasReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
Description
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | keras | all versions | 3.12.3pip install --upgrade 'keras==3.12.3' |
| 🐍PyPI | keras | ≥ 3.13.0&&< 3.15.0 | 3.15.0pip install --upgrade 'keras==3.15.0' |
Affected Products
keraskerasDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for keras, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update keras to 3.12.3 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-5gwj-m78q-7pq3 is resolved across your whole dependency graph.
Workarounds
Do not deserialise data from untrusted sources: where the format allows it, restrict deserialisation to an explicit allowlist of expected types, and prefer a data-only format (JSON, Protobuf) over one that can reconstruct arbitrary objects until you can upgrade.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
This is an Important arbitrary code execution vulnerability in the Keras deep learning library, impacting Red Hat OpenShift AI components. The flaw arises from improper deserialization in the `Lambda` layer, where a security safeguard is bypassed if `safe_mode` is not explicitly enabled. Exploitation requires user…
To reduce exposure, only deserialize Keras models from trusted sources. When deserializing models, explicitly enable `safe_mode` by wrapping the deserialization call within a `SafeModeScope(True)` context. This ensures the deserialization safeguard is enforced, preventing the execution of arbitrary code.Source: Red Hat security advisory for GHSA-5gwj-m78q-7pq3 (CC BY 4.0)
| Product | Fixed in | Advisory |
|---|---|---|
| Red Hat OpenShift AI 3.4 | rhoai/odh-kserve-storage-initializer-rhel9:1787073479 | RHSA-2026:60520 |
Frequently Asked Questions
Is GHSA-5gwj-m78q-7pq3 in your dependencies?
Find it across PyPI, including transitive dependencies.