CVE-2025-71176

6.8 MEDIUM

📋 TL;DR

This vulnerability in pytest allows local users on UNIX systems to cause denial of service or potentially escalate privileges by exploiting predictable temporary directory names. It affects pytest installations where users can create directories in /tmp. The risk is limited to systems with multiple local users or shared environments.

💻 Affected Systems

Products:
  • pytest
Versions: All versions through 9.0.2
Operating Systems: UNIX-like systems (Linux, macOS, BSD)
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects UNIX systems; Windows is not vulnerable. Requires local user access to create directories in /tmp.

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Local privilege escalation allowing an attacker to execute arbitrary code with the privileges of another user running pytest tests.

🟠

Likely Case

Denial of service by interfering with pytest's temporary directory structure, causing test failures or system instability.

🟢

If Mitigated

Minimal impact if proper file permissions restrict /tmp directory access or if pytest runs in isolated environments.

🌐 Internet-Facing: LOW - This is a local privilege escalation vulnerability requiring local system access.
🏢 Internal Only: MEDIUM - Risk exists in multi-user systems, development environments, or CI/CD pipelines where multiple users might run pytest.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires local user access and knowledge of other users' pytest sessions. The vulnerability is well-documented in public disclosures.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: pytest 9.0.3 and later

Vendor Advisory: https://github.com/pytest-dev/pytest/issues/13669

Restart Required: No

Instructions:

1. Upgrade pytest using pip: 'pip install --upgrade pytest>=9.0.3' 2. Verify the upgrade with 'pytest --version' 3. No restart required as this is a Python package update.

🔧 Temporary Workarounds

Set custom pytest temporary directory

linux

Override the default temporary directory location to a secure, user-specific path

export PYTEST_DEBUG_TEMPROOT=/secure/user/specific/path
pytest --basetemp=/secure/user/specific/path

Restrict /tmp directory permissions

linux

Set stricter permissions on /tmp to prevent directory creation by unauthorized users

chmod 1777 /tmp
chown root:root /tmp

🧯 If You Can't Patch

  • Run pytest in isolated containers or virtual environments with restricted filesystem access
  • Implement strict user separation and ensure pytest runs with minimal privileges

🔍 How to Verify

Check if Vulnerable:

Check pytest version with 'pytest --version' and verify if it's 9.0.2 or earlier on a UNIX system.

Check Version:

pytest --version

Verify Fix Applied:

After upgrading, confirm version is 9.0.3 or later with 'pytest --version' and test that temporary directories use secure naming.

📡 Detection & Monitoring

Log Indicators:

  • Failed pytest test runs due to temporary directory conflicts
  • Unauthorized directory creation attempts in /tmp/pytest-of-* patterns

Network Indicators:

  • None - this is a local filesystem vulnerability

SIEM Query:

search 'pytest' AND ('/tmp/pytest-of' OR 'temporary directory') in system logs for access violations

🔗 References

📤 Share & Export