Keras archive extraction utilities allow path traversal and arbitrary file writes
Keras archive extraction utilities validated member paths against the current working directory instead of the extraction destination, allowing path traversal. An attacker could write files outside the intended directory, potentially overwriting configuration files or injecting code.
keras-team/keras
Originally disclosed on huntr
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.
From the GitHub Advisory Database (GHSA-hqp4-2352-xf5r, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could write arbitrary files outside the extraction directory, potentially overwriting configuration files, injecting malicious code, or corrupting machine learning datasets and pipelines.
What the attacker needed
Process CWD is filesystem root (e.g. Docker); attacker supplies a malicious archive; Python 3.11 lacks filter='data' safety net
The fix
Keras 3.14.0 fixed the issue by validating against the extraction destination and handling blocked zip entries correctly.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you unpack a zip or tar file, the program should check that each file inside stays within the folder you chose. Keras checked against the folder the program was started from instead, so a malicious archive could slip files into other places on the disk.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.