Keras versions up to 3.15.0 contain a vulnerability that allows denial of service (DoS) via loading malicious .keras model files. The issue arises from unvalidated dataset shapes and sizes during model loading, causing unbounded memory allocation and potential out-of-memory crashes. This vulnerability bypasses a previous fix and affects machine learning pipelines processing untrusted models.
A vulnerability in keras-team/keras versions <= 3.14.0 allows arbitrary local HDF5 file content disclosure due to improper handling of HDF5 ExternalLinks. The `KerasFileEditor` and `keras.saving.load_weights` functions bypass the `safe_get_h5_group` and `safe_get_h5_dataset` helpers, which are designed to reject ExternalLinks and SoftLinks. This results in automatic dereferencing of links to external HDF5 files, enabling attackers to disclose sensitive data from the victim's local filesystem. Specifically, `KerasFileEditor` extracts attributes and datasets from linked files into its internal structures, while `keras.saving.load_weights` loads weights from linked files into the user's model. This issue can be exploited by providing a malicious `.h5`, `.weights.h5`, or `.keras` file containing ExternalLinks.
CVE-2026-12484 is a high-severity vulnerability in keras-team/keras version 3.15.0 that allows unsafe deserialization of attacker-controlled PyTorch pickle data via the public method keras.layers.TorchModuleWrapper.from_config. This method calls torch.load without requiring an explicit unsafe opt-in or enforcing safe deserialization, potentially leading to arbitrary code execution if untrusted Keras layer configurations are processed. The vulnerability exists because safe deserialization is only enforced when explicitly guarded by Keras safe mode, which is not the default behavior.
A vulnerability in keras-team/keras version 3.12.0 allows an attacker to craft a malicious tar archive that bypasses the `filter_safe_tarinfos` validation in `keras/src/utils/file_utils.py`. Specifically, symlink entries are not subjected to the same `is_path_in_dir` validation as regular file entries, allowing symlinks to be created outside the intended extraction directory. This can lead to symlink-based file read, file overwrite, or directory escape attacks. The issue is particularly impactful on Python 3.10 and 3.11, where `filter_safe_tarinfos` is the sole defense against tar path traversal. This vulnerability is distinct from CVE-2025-12060 and other previously reported issues.
CVE-2026-12481 is a high-severity vulnerability in keras-team/keras version 3.14.0 involving unsafe deserialization in the Lambda layer. The issue arises because the _raise_for_lambda_deserialization() function does not properly enforce safe-mode when safe_mode is None, which is the default outside a SafeModeScope context. This allows attacker-controlled marshal bytecode to be deserialized, potentially leading to arbitrary OS-level code execution. The vulnerability affects calls to keras.layers.deserialize(config), keras.models.clone_model(model), and Lambda.from_config(config) without SafeModeScope(True). The product is a cloud service, and a patch is available. No known exploits are reported in the wild.
Keras versions before 3.12.2 and between 3.12.3 and before 3.14.1 contain a vulnerability that allows an attacker to craft malicious model files with Virtual Datasets referencing external files. Loading such models can cause unintended reading of external files, potentially disclosing sensitive information. This issue is due to incomplete validation of the dataset's virtual property. The vulnerability is fixed in versions 3.12.2 and 3.14.1.
CVE-2026-12479 is a path traversal vulnerability in keras-team/keras version 3.14.0 affecting the DiskIOStore.make method. It arises from improper sanitization of user-provided layer names used in directory path construction, allowing directory traversal sequences despite restrictions on forward slashes. This can enable an attacker to escape the intended temporary directory and perform unauthorized file system operations such as creating directories or writing files in arbitrary locations.
Keras versions prior to 3.14.0 are vulnerable to a path traversal issue in the archive extraction utilities located in `keras/src/utils/file_utils.py`. The functions `filter_safe_tarinfos()` and `filter_safe_zipinfos()` validate archive member paths against the process current working directory (CWD) instead of the actual extraction destination. When the process runs with CWD set to `/`, which is common in Docker containers, CI/CD runners, and Jupyter environments, the validation boundary becomes the filesystem root, allowing traversal paths to bypass the security check. Additionally, the zip filter contains a bug that causes an `AttributeError` when a blocked entry is encountered, leading to incomplete extraction. Furthermore, Python 3.11 installations lack the `filter="data"` safety net, leaving them entirely reliant on the flawed CWD-based filter. Exploitation of this vulnerability can result in arbitrary file writes outside the intended extraction directory, enabling attackers to overwrite configuration files, inject malicious code, or corrupt machine learning datasets and pipelines.
A vulnerability in the `TFSMLayer` class of the `keras` package, version 3.13.0, allows attacker-controlled TensorFlow SavedModels to be loaded during deserialization of `.keras` models, even when `safe_mode=True`. This bypasses the security guarantees of `safe_mode` and enables arbitrary attacker-controlled code execution during model inference under the victim's privileges. The issue arises due to the unconditional loading of external SavedModels, serialization of attacker-controlled file paths, and the lack of validation in the `from_config()` method.
Keras version 3.11.3 is affected by a path traversal vulnerability in the keras.utils.get_file() function when extracting tar archives. The vulnerability arises because the function uses Python's tarfile.extractall() method without the security-critical filter='data' parameter. Although Keras attempts to filter unsafe paths using filter_safe_paths(), this filtering occurs before extraction, and a PATH_MAX symlink resolution bug triggers during extraction. This bug causes symlink resolution to fail due to path length limits, resulting in a security bypass that allows files to be written outside the intended extraction directory. This can lead to arbitrary file writes outside the cache directory, enabling potential system compromise or malicious code execution. The vulnerability affects Keras installations that process tar archives with get_file() and does not affect versions where this extraction method is secured with the appropriate filter parameter.
The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True.
One can create a specially crafted .h5/.hdf5 model archive that, when loaded via Model.load_model, will trigger arbitrary code to be executed.
This is achieved by crafting a special .h5 archive file that uses the Lambda layer feature of keras which allows arbitrary Python code in the form of pickled code. The vulnerability comes from the fact that the safe_mode=True option is not honored when reading .h5 archives.
Note that the .h5/.hdf5 format is a legacy format supported by Keras 3 for backwards compatibility.
The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True.
One can create a specially crafted .keras model archive that, when loaded via Model.load_model, will trigger arbitrary code to be executed. This is achieved by crafting a special config.json (a file within the .keras archive) that will invoke keras.config.enable_unsafe_deserialization() to disable safe mode. Once safe mode is disable, one can use the Lambda layer feature of keras, which allows arbitrary Python code in the form of pickled code. Both can appear in the same archive. Simply the keras.config.enable_unsafe_deserialization() needs to appear first in the archive and the Lambda with arbitrary code needs to be second.