Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-62239

CVE-2026-62239: FlashAttention Privilege Escalation Flaw

CVE-2026-62239 is a privilege escalation vulnerability in FlashAttention that allows local attackers to exploit a symlink attack during build time. This post explains its impact, affected versions, and mitigation steps.

Published:

CVE-2026-62239 Overview

CVE-2026-62239 is a symlink attack vulnerability in FlashAttention versions through 2.8.3.post1. The flaw resides in the download_and_copy() function within hopper/setup.py, which extracts NVIDIA toolchain archives without validating symbolic links or filtering tar members. A local attacker who can write to the predictable cache directory can pre-plant a symlink before the build runs. When the vulnerable extraction routine processes the tar archive, it follows the attacker-controlled symlink and writes extracted binaries to a location of the attacker's choosing. The issue is tracked under CWE-59: Improper Link Resolution Before File Access and was fixed in commit 0816ef1.

Critical Impact

Local attackers can achieve arbitrary file write with the build user's privileges by planting symlinks in the FlashAttention build cache before hopper/setup.py extracts NVIDIA toolchain tarballs.

Affected Products

  • FlashAttention through version 2.8.3.post1
  • hopper/setup.py build script in the Dao-AILab/flash-attention repository
  • Systems building the Hopper backend of FlashAttention from source

Discovery Timeline

  • 2026-07-13 - CVE-2026-62239 published to NVD
  • 2026-07-15 - Last updated in NVD database

Technical Details for CVE-2026-62239

Vulnerability Analysis

The FlashAttention Hopper build script downloads prebuilt NVIDIA CUDA toolchain archives and extracts them into a cache directory before compiling the CUDA kernels. The download_and_copy() helper in hopper/setup.py calls tarfile.extractall() on those archives without applying a member filter or resolving symbolic links against the destination directory.

Because the cache path is predictable and reused across builds, a local attacker on the same host can create a symlink at an expected member name inside the cache directory. When the build later extracts the archive, tarfile follows the attacker-planted symlink and writes contents to the linked target. The attacker gains arbitrary file write with the privileges of the user running pip install or python setup.py.

Root Cause

The root cause is unsafe tar extraction. Python's tarfile.extractall() historically honors symlink and hardlink members without validating that the resolved path stays inside the extraction directory. Since PEP 706 the data filter mitigates this, but hopper/setup.py did not opt in and did not perform any manual member validation. This maps to CWE-59: Improper Link Resolution Before File Access.

Attack Vector

Exploitation requires local access and user interaction — the victim must trigger a FlashAttention build. The attacker pre-creates a symlink such as <cache_dir>/cuda_nvcc/bin/nvcc pointing to a sensitive file (for example, a file under ~/.ssh/, a Python site-packages module, or a wrapper script in ~/.local/bin). The next FlashAttention build overwrites that target with archive contents, enabling code execution the next time the poisoned file is read or executed.

python
# Security patch applied in commit 0816ef1 to hopper/setup.py
def safe_extractall(tar, path):
    """Extract a tar stream, refusing members that would escape ``path``.

    Uses the PEP 706 ``data`` filter when the interpreter supports it (added in
    3.12, backported to 3.10.12 / 3.11.4). On older interpreters the filter
    keyword does not exist, so we validate each member's resolved path stays
    inside ``path`` and reject link members before extracting.
    """
    dest = os.path.realpath(path)
    if hasattr(tarfile, "data_filter"):
        tar.extractall(path=dest, filter="data")
        return

    def stays_inside(resolved):
        return resolved == dest or resolved.startswith(dest + os.sep)

    for member in tar:
        target = os.path.realpath(os.path.join(dest, member.name))
        if not stays_inside(target):
            raise RuntimeError(f"Refusing tar member outside extract dir: {member.name!r}")
        if member.issym() or member.islnk():
            # Validate link targets resolve inside dest before extracting.
            ...

Source: Dao-AILab/flash-attention commit 0816ef1

Detection Methods for CVE-2026-62239

Indicators of Compromise

  • Unexpected symbolic links inside the FlashAttention build cache directory prior to a build, particularly under paths matching NVIDIA toolchain member names such as cuda_nvcc/bin/* or cuda_cudart/lib/*.
  • Files outside the build cache with modification timestamps aligned to a recent pip install flash-attn or python setup.py invocation on the Hopper backend.
  • Presence of FlashAttention versions at or below 2.8.3.post1 in build environments shared with untrusted local users.

Detection Strategies

  • Audit filesystem writes performed by python, pip, and setup.py processes during FlashAttention builds and flag writes that escape the expected build and install directories.
  • Monitor for symlink() and link() syscalls targeting FlashAttention cache paths executed by non-build user identities.
  • Compare installed FlashAttention commit hashes against the fixed commit 0816ef1 in the Dao-AILab/flash-attention repository.

Monitoring Recommendations

  • Enable filesystem integrity monitoring on shared build hosts, CI runners, and container images that compile FlashAttention.
  • Log and alert on tarfile.extractall() calls in build scripts through Python audit hooks (sys.addaudithook) where feasible.
  • Track outbound package installs and correlate with subsequent file modifications outside the site-packages tree.

How to Mitigate CVE-2026-62239

Immediate Actions Required

  • Upgrade FlashAttention to a build that includes commit 0816ef1 or later before running hopper/setup.py.
  • Perform FlashAttention builds only in single-tenant environments where no untrusted local user can write to the build cache directory.
  • Delete any existing FlashAttention build cache directories and recreate them with restrictive permissions (owner-only) before rebuilding.

Patch Information

The vulnerability is fixed in commit 0816ef1 of the Dao-AILab/flash-attention repository, delivered via pull request #2702. The patch introduces safe_extractall(), which opts into the PEP 706 data filter when the Python interpreter supports it and otherwise validates each tar member's resolved path and link targets. See the VulnCheck advisory and issue #2637 for background.

Workarounds

  • Run FlashAttention builds under a dedicated, non-shared user account with an isolated HOME and cache directory.
  • Point the build cache to a freshly created directory with mode 0700 before each build to prevent pre-planted symlinks.
  • Use Python 3.12 (or 3.10.12 / 3.11.4 and later) and set PYTHONTARFILEFILTER=data to enforce safe tar extraction globally.
bash
# Configuration example: harden the FlashAttention build environment
export PYTHONTARFILEFILTER=data
BUILD_USER=flashbuild
BUILD_CACHE=/var/lib/${BUILD_USER}/flash-attn-cache

sudo useradd -m -s /bin/bash ${BUILD_USER}
sudo -u ${BUILD_USER} rm -rf ${BUILD_CACHE}
sudo -u ${BUILD_USER} install -d -m 0700 ${BUILD_CACHE}

sudo -u ${BUILD_USER} \
  FLASH_ATTN_CACHE_DIR=${BUILD_CACHE} \
  pip install --no-binary flash-attn \
    "git+https://github.com/Dao-AILab/flash-attention@0816ef1"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.