CVE-2025-71176: 
Python vulnerability analysis and mitigation

Overview

CVE-2025-71176 is a vulnerability in pytest (through version 9.0.2) on UNIX systems involving insecure temporary directory handling that allows local users to cause a denial of service or possibly gain privileges. The flaw was reported by Michael Orlitzky on August 24, 2025, disclosed publicly via the oss-security mailing list on January 21, 2026, and assigned a CVE on January 22, 2026. It affects all pytest versions up to and including 9.0.2 on UNIX platforms; Windows is not affected. The CVSS v3.1 base score is 6.8 (Medium), assigned by MITRE (Red Hat Advisory, oss-security, GitHub Issue).

Technical details

The root cause is classified as CWE-379 (Creation of Temporary File in Directory with Insecure Permissions). pytest creates a predictable temporary directory at /tmp/pytest-of-{user} and performs a UID ownership check to prevent tampering; however, this check follows symlinks and is subject to a time-of-check/time-of-use (TOCTOU) race condition. An attacker on the same system can pre-create a symlink at /tmp/pytest-of-{victim} pointing to an attacker-controlled directory before pytest runs, causing pytest to write test artifacts into that directory and potentially alter its permissions. The Linux kernel's fs.protected_symlinks and fs.protected_hardlinks sysctls mitigate some attack vectors but are not universally enabled and are Linux-specific (GitHub Issue, oss-security).

Impact

Successful exploitation can result in denial of service (preventing pytest from running or corrupting test artifacts) or privilege escalation, where an attacker gains write access to directories owned by another user and may manipulate their contents. The vulnerability also allows pytest to change permissions on attacker-chosen directories, potentially exposing sensitive data or enabling further attacks. The impact is limited to local, multi-user UNIX environments such as shared CI/CD systems or cloud build environments where multiple users share a common /tmp (oss-security, Red Hat Advisory).

Exploitability

No public exploit code or weaponized exploit kit has been identified for this vulnerability. The EPSS score is extremely low at 0.000040, indicating minimal probability of exploitation in the wild, and it is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. Exploitation requires local access to a multi-user UNIX system and the ability to create symlinks in /tmp before the target user runs pytest. No threat actor attribution has been reported (Feedly, oss-security).

Exploitation steps

  1. Reconnaissance: Identify a target multi-user UNIX system where pytest is used by another user (e.g., a shared CI server or cloud build environment). Confirm that fs.protected_symlinks is disabled (check via sysctl fs.protected_symlinks).
  2. Pre-create symlink: As the attacker, create a symlink at /tmp/pytest-of-{victim_username} pointing to an attacker-controlled directory (e.g., ln -s /home/attacker/target /tmp/pytest-of-victim).
  3. Wait for pytest execution: Wait for the victim user to run pytest, or trigger it indirectly through a CI pipeline or scheduled job.
  4. Exploit TOCTOU/symlink race: When pytest starts, it calls rootdir.mkdir(mode=0o700, exist_ok=True) and then checks ownership via rootdir.stat(). Because stat() follows symlinks, it checks the ownership of the attacker-controlled target directory rather than the symlink itself.
  5. Achieve impact: If the attacker owns the target directory, the UID check passes and pytest writes test artifacts into the attacker-controlled location. Pytest may also call chmod on the directory, altering permissions on the attacker-chosen path, potentially enabling further privilege escalation or data manipulation (GitHub Issue, oss-security).

Indicators of compromise

  • File System: Presence of a symlink at /tmp/pytest-of-{username} pointing to an unexpected directory (rather than a real directory owned by the user); unexpected files or directories appearing in locations outside /tmp after pytest runs.
  • Logs: System audit logs (auditd) showing symlink or lstat/stat calls on /tmp/pytest-of-* paths by a user other than the expected pytest runner; unexpected chmod or chown operations on directories not owned by the pytest-running user.
  • Process: pytest processes writing to directories outside the expected /tmp/pytest-of-{user} subtree; unexpected permission changes on directories in /tmp or elsewhere attributable to the pytest process (GitHub Issue, oss-security).

Mitigation and workarounds

The fix is available in pytest version 9.0.3 and later (pytest 9.0.3 release). Users unable to upgrade immediately should create a secure temporary directory using mktemp -d and override pytest's default via the PYTEST_DEBUG_TEMPROOT environment variable or Python's tempfile.gettempdir() environment variables. On Linux, enabling the following kernel sysctls provides additional protection: fs.protected_symlinks=1, fs.protected_hardlinks=1, fs.protected_fifos=2, and fs.protected_regular=2. IBM has issued patches for affected products including IBM Engineering AI Hub, IBM InfoSphere Optim Archive Viewer, and IBM Maximo Application Suite (oss-security, IBM Engineering AI Hub, IBM Optim Archive Viewer, IBM Maximo).

Community reactions

The vulnerability was disclosed by Michael Orlitzky via the oss-security mailing list, who noted that denial of service is trivial and code execution is possible on multi-user systems, while acknowledging the issue is less impactful for single-user environments. The pytest GitHub issue remains open with a "help wanted" label, indicating the maintainers are seeking expert input on a robust fix. A Reddit thread in r/learnpython discussed the vulnerability, reflecting moderate community interest. SUSE issued a security update (SUSE-SU-2026:1744-1) addressing the issue in their distributions (oss-security, GitHub Issue, SUSE Advisory).

Additional resources

Linux Distribution fix status

Fix availability across major Linux distributions and their releases.

Debian

Affected

bookworm

pytest

Affected

sid

pytest

Affected

trixie

pytest

Affected

Ubuntu

Unknown

bionic (esm-apps)

pytest

Unknown

devel

pytest

Unknown

focal (esm-apps)

pytest

Unknown

jammy

pytest

Unknown

jammy (esm-apps)

pytest

Unknown

noble

pytest

Unknown

noble (esm-apps)

pytest

Unknown

resolute

pytest

Unknown

RHEL / CentOS

Affected

OpenShift

pytest.src

Affected

RHEL 8

pytest.src

Affected

RHEL 9

pytest.src

Affected

RHEL 10

pytest.src

Affected

Source: This report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-mpqx-q82w-9x46HIGH7.5
  • Python logoPython
  • graphql-core
NoYesOct 25, 2026
GHSA-4gm2-62xx-xwvxMEDIUM5.3
  • Python logoPython
  • aynops
NoYesOct 25, 2026
GHSA-jm75-qwf5-vg52MEDIUMN/A
  • Python logoPython
  • exmergo-dex-core
NoYesOct 25, 2026
GHSA-f3jf-cv9h-7c3gHIGHN/A
  • Python logoPython
  • exmergo-dex-core
NoYesOct 25, 2026
GHSA-28xv-9wpg-c42rHIGHN/A
  • Python logoPython
  • exmergo-dex-core
NoYesOct 25, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management