VYPR
Unrated severityNVD Advisory· Published Jun 30, 2021· Updated Aug 4, 2024

CVE-2021-35958

CVE-2021-35958

Description

CVE-2021-35958 allows arbitrary file overwrite in TensorFlow's tf.keras.utils.get_file when extracting untrusted archives.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

CVE-2021-35958 allows arbitrary file overwrite in TensorFlow's tf.keras.utils.get_file when extracting untrusted archives.

Vulnerability

The vulnerability resides in tf.keras.utils.get_file when called with extract=True. The function uses Python's tarfile.extractall() without validating archive contents, allowing path traversal via symlinks or entries with absolute paths [1][2]. Affected versions include TensorFlow through 2.5.0 [4]. The vendor disputes this as a security issue, stating the function is not intended for untrusted archives [4].

Exploitation

An attacker must craft a malicious tar archive containing entries that overwrite files outside the extraction directory (e.g., using ../ paths or symbolic links). The victim must call tf.keras.utils.get_file with extract=True on this archive, typically by downloading it from an untrusted source. No additional authentication or privileges are required beyond the ability to supply the archive [2][4].

Impact

Successful exploitation allows arbitrary file write or overwrite on the host filesystem. This can lead to code execution (e.g., overwriting Python scripts or configuration files), privilege escalation, or denial of service. The attacker controls the content and location of the written files [4].

Mitigation

No official patch has been released by the TensorFlow team; the vendor considers the behavior by design [4]. Users should avoid using extract=True with untrusted archives. As a workaround, manually validate or extract archives using a safer method. Python 3.12+ introduced extraction filters that mitigate such attacks, but TensorFlow does not enforce them [1]. The vulnerability is not listed in CISA's Known Exploited Vulnerabilities catalog as of this writing.

AI Insight generated on May 27, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

3

Patches

0

No patches discovered yet.

Vulnerability mechanics

Root cause

"tf.keras.utils.get_file with extract=True passes the downloaded archive to Python's tarfile.extractall(), which prior to Python 3.14 uses a fully_trusted default filter that does not prevent path traversal or absolute path writes."

Attack vector

An attacker crafts a tar archive containing members with absolute paths (e.g., `/etc/cron.d/malicious`) or path-traversal components (e.g., `../../etc/passwd`). The victim downloads this archive using `tf.keras.utils.get_file` with `extract=True`. Because `tarfile.extractall()` prior to Python 3.14 uses the `fully_trusted` filter by default, the archive's members are extracted to the attacker-controlled paths, overwriting arbitrary files on the victim's system. No authentication or special network position is required beyond the ability to serve or trick the victim into fetching the malicious archive.

Affected code

The vulnerability resides in TensorFlow's `tf.keras.utils.get_file` function when called with `extract=True`. The function uses Python's `tarfile.extractall()` to extract downloaded archives, but prior to Python 3.14 the default extraction filter was equivalent to `fully_trusted`, meaning no path traversal or symlink checks were applied. This allows a crafted tar archive to write files to arbitrary locations on the filesystem.

What the fix does

The advisory does not include a patch for TensorFlow itself. Instead, the fix is described in the Python documentation: starting with Python 3.14, the default extraction filter for `tarfile.extractall()` was changed from `fully_trusted` to `data`, which rejects absolute paths, paths outside the destination directory, and other dangerous archive members. Users of earlier Python versions must either upgrade to Python 3.14+ or explicitly pass a safe filter (e.g., `filter='data'`) when calling extraction functions.

Preconditions

  • inputThe victim must call tf.keras.utils.get_file with extract=True on a URL pointing to a malicious tar archive.
  • configThe victim's Python version must be older than 3.14, where tarfile.extractall() defaults to the fully_trusted filter.

Generated on May 30, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.