Keras Safe Mode Bypass Vulnerability: Arbitrary Code Execution Risk
Summary
GHSA-pwq7-2gvj-vg9v: Duplicate Advisory: Keras safe mode bypass vulnerability. Affects keras versions >= 3.0.0, < 3.11.0. Fixed in 3.11.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Keras is an open-source deep learning library written in Python, designed to enable fast experimentation with neural networks. It provides a user-friendly API and supports multiple backends, making it a popular choice among data scientists and machine learning practitioners. However, versions 3.0.0 through 3.10.0 of Keras contain a vulnerability in the Model.load_model method that allows attackers to execute arbitrary code by loading specially crafted model archives.
Vulnerability Detail
The vulnerability arises from a safe mode bypass in the Model.load_model method of Keras. This flaw allows an attacker to craft a malicious .keras model archive that, when loaded by a user, can execute arbitrary code on the user's machine. The potential ramifications include unauthorized access to sensitive data, system compromise, and the execution of malicious payloads. This vulnerability is classified under CWE-502, which pertains to deserialization of untrusted data.
How To Fix
Latest published version: 3.15.1 as of 22 Oct 2026
pip install --upgrade "keras==3.15.1"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
3.11.0
This is the first release that contains the fix.
pip install --upgrade "keras==3.11.0"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, avoid loading model files from untrusted sources. If you must load a model, ensure it is from a verified and secure origin to minimize the risk of executing malicious code.
Conclusion
The Keras safe mode bypass vulnerability poses a significant risk by allowing arbitrary code execution through malicious model files. Users are strongly advised to update to version 3.11.0 or later to mitigate this risk. Additionally, employing best practices when loading models can further enhance security.
See every vulnerability recorded for keras →
FAQ
Keras versions 3.0.0 through 3.10.0 are affected by the safe mode bypass vulnerability.
Loading a malicious .keras model can lead to arbitrary code execution, potentially compromising your system and data.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
Yes, the vulnerability has been patched in Keras version 3.11.0. Users should upgrade to this version or later.
Vulert monitors and alerts for open-source vulnerabilities in your software using just the Pipfile.lock. It provides real-time alerts to help you maintain secure applications.
References
Related vulnerabilities
Recent vulnerabilities recorded for keras.