HIGH 8.1

CVE-2026-11816: Keras Path Traversal in Archive Extraction (CVSS 8.1)

Keras, a widely-used machine learning library, contains a path traversal vulnerability in its archive extraction functions that can allow attackers to write files outside the intended extraction directory. The vulnerability affects Keras versions before 3.14.0 and stems from validation logic that checks paths against the wrong directory reference—the process's current working directory instead of where files are actually being extracted. In common environments like Docker containers and Jupyter notebooks where the working directory is set to the filesystem root, this check becomes ineffective. An attacker can craft a malicious archive that, when extracted by a vulnerable Keras application, overwrites critical files on the system or injects malicious code into machine learning pipelines.

Source data · NVD / CISA · public domain

CVSS
3.1 · 8.1 HIGH · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N
Weaknesses (CWE)
CWE-22
Affected products
1 configuration(s)
Published / Modified
2026-06-11 / 2026-07-15

NVD description (verbatim)

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.

6 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability exists in `keras/src/utils/file_utils.py`, specifically in the `filter_safe_tarinfos()` and `filter_safe_zipinfos()` functions. These functions are intended to prevent directory traversal attacks during archive extraction by validating member paths. However, they validate against `os.getcwd()` rather than against the intended extraction destination directory. When the current working directory is `/` (common in containerized and CI/CD environments), the validation boundary becomes the root filesystem, rendering the check useless for paths that traverse outside `/`. Additionally, the ZIP file filter has a bug where an `AttributeError` is raised when encountering a blocked entry, causing extraction to fail before the flawed validation is even applied. Python 3.11 users face additional risk because the standard library's `filter="data"` parameter—which provides a secondary safety mechanism—is unavailable, leaving only the broken CWD-based validation in effect.

Business impact

Successful exploitation enables arbitrary file writes to the filesystem, with implications across multiple business functions. Attackers could overwrite configuration files to alter application behavior, inject malicious code into deployed models or training pipelines, corrupt machine learning datasets leading to model poisoning, or plant backdoors in production systems. For organizations using Keras in data science workflows, model serving, or automated ML training, this vulnerability directly threatens model integrity and operational security. The impact is elevated in multi-tenant environments or shared infrastructure where attacker-controlled input might be processed through vulnerable Keras extraction routines.

Affected systems

Keras versions prior to 3.14.0 are vulnerable. The risk profile varies by environment and Python version: Python 3.11+ users have some mitigation from the standard library's `filter="data"` parameter if Keras uses it, but Python 3.11 installations lack this safety net entirely. All versions are at risk in environments where the process CWD is `/`, including Docker containers, Kubernetes pods, serverless functions, CI/CD runners (GitHub Actions, GitLab CI), and Jupyter notebooks running in standard configurations. Organizations should verify their installed Keras version and deployment contexts.

Exploitability

The vulnerability requires user interaction (UI=R in the CVSS vector), meaning an attacker must trick a user or automated process into extracting an attacker-controlled archive using a vulnerable Keras function. No authentication is required (PR=N), and the attack is network-accessible (AV:N). The barrier to exploitation is low: an attacker crafts a malicious tar or zip file with path traversal sequences (e.g., `../../etc/passwd`) and delivers it to a target. If that target's application uses Keras to extract the archive, and if the process CWD happens to be `/`, the traversal succeeds. In automated environments (batch processing, model retraining pipelines), this interaction requirement may be satisfied without human involvement, increasing practical risk.

Remediation

Upgrade Keras to version 3.14.0 or later. This release corrects the path validation logic to check against the actual extraction destination rather than the process CWD, and fixes the ZIP filter bug. After patching, validation will correctly reject traversal paths regardless of where the process is running. There are no known workarounds for the CWD-based check itself; patching is the primary remediation. As a complementary measure, organizations should review archive handling workflows and consider additional controls such as extracting archives into isolated temporary directories with restricted permissions, validating archive contents before extraction, or using sandboxing for archive processing.

Patch guidance

Apply Keras version 3.14.0 or later. Most Python environments can update via pip with `pip install --upgrade keras>=3.14.0`. For containerized deployments, update the base image or requirements.txt to pin Keras to 3.14.0 or higher, then rebuild and redeploy containers. For offline or air-gapped environments, download the patched Keras wheel and install locally. Verify the upgrade by checking the installed version: `python -c 'import keras; print(keras.__version__)'` should return 3.14.0 or later. Test patched systems against archive extraction workflows used in production to ensure no regression.

Detection guidance

Monitor for suspicious archive extraction patterns: look for tar or zip files being processed by Keras with path components containing `../` or similar traversal sequences. Review access logs for unexpected file creation or modification outside normal application directories, particularly in system directories like `/etc`, `/tmp`, or configuration paths. In containerized environments, examine image build logs for archive extraction during layer creation. For runtime detection, instrument Keras archive functions or monitor filesystem calls (using auditd on Linux or similar tools) for write operations to unexpected directories. Python application logging can be enhanced to record archive filenames and extraction destinations. In development, code review should flag any use of `keras.utils.get_file()` or direct calls to `filter_safe_tarinfos`/`filter_safe_zipinfos()` without explicit destination validation.

Why prioritize this

This vulnerability warrants high priority due to its CVSS 8.1 score, the prevalence of Keras in machine learning infrastructure, and the widespread use of containerized deployments where the exploitation condition (CWD=/`) is default. The attack surface includes automated training pipelines, model distribution systems, and data processing workflows that may process untrusted archives. The impact spans confidentiality and integrity. While exploitation requires user interaction, many modern ML platforms execute extraction routines automatically as part of data loading or model deployment. The fix is straightforward and low-risk, making remediation feasible at scale.

Risk score, explained

Keras is assigned CVSS 3.1 score 8.1 (HIGH) reflecting: attack vector Network (AV:N), allowing remote delivery of malicious archives; attack complexity Low (AC:L), as crafting a traversal-containing archive is trivial; privileges required None (PR:N); user interaction Required (UI:R), necessitating that a process extracts the attacker's archive; scope Unchanged (S:U); confidentiality impact High (C:H), as arbitrary file writes can read sensitive files or extract data; and integrity impact High (I:H), as files can be overwritten or injected. Availability impact is None (A:N) as the vulnerability does not directly disable services, though corrupted files could indirectly cause outages. The score reflects the combination of broad network reach, ease of exploitation, and dual impact on confidentiality and integrity, but is tempered by the user interaction requirement.

Frequently asked questions

Does this vulnerability affect me if I use Keras but never extract archives?

No, not directly. The vulnerability is specific to the archive extraction utilities in `keras/src/utils/file_utils.py`. If your use of Keras does not involve extracting tar or zip files (e.g., you only use Keras for model training or inference on pre-extracted data), you are not exposed. However, if your application uses `keras.utils.get_file()` with URL-based model downloads, check whether that function internally extracts archives—it may use the vulnerable code path.

I'm running Keras in a container with a specific working directory, not `/`. Am I still at risk?

Your risk is reduced but not eliminated. If your container's CWD is set to something other than `/` (e.g., `/app`), the validation will check against `/app` instead of `/`, potentially allowing traversal only within `/app` rather than the entire filesystem. However, this is still a security flaw and not a reliable mitigation. You should upgrade to 3.14.0 regardless.

What versions of Python are most affected?

All Python versions running Keras 3.13.x and earlier are vulnerable. Python 3.11 users face heightened risk because the standard library's `filter="data"` safety feature is unavailable, leaving only the broken CWD-based filter. Python 3.12+ may have additional protections depending on how Keras integrates library features, but this is not a substitute for patching Keras itself.

Can I trust my archive sources to mitigate this?

No. While only extracting archives from trusted sources reduces risk, a trusted source could be compromised, or an insider with access to an archive distribution system could inject traversal payloads. The vulnerability is in Keras's validation logic, not your upload controls. Patching Keras is the proper fix.

This analysis is based on vendor-provided information and public CVE data current as of the stated publication and modification dates. While efforts are made to ensure accuracy, SEC.co makes no warranty regarding completeness or fitness for any particular purpose. Organizations should verify patch availability and applicability to their specific Keras deployment before applying recommendations. This document does not constitute legal or compliance advice. For the authoritative vulnerability details, consult the official Keras project advisory and NIST CVE database. Source: NVD (public-domain), retrieved 2026-07-20. Analysis generated by SEC.co (claude-haiku-4-5).