CVE-2025-6075

5.5 MEDIUM

📋 TL;DR

This CVE describes a denial-of-service vulnerability in Python's os.path.expandvars() function. When user-controlled input is passed to this function, an attacker can cause performance degradation by crafting malicious environment variable expansions. This affects any Python application that uses os.path.expandvars() with untrusted input.

💻 Affected Systems

Products:
  • Python
Versions: All versions before fixes in CPython commits
Operating Systems: All platforms running Python
Default Config Vulnerable: ✅ No
Notes: Only vulnerable when os.path.expandvars() is called with user-controlled input. Not all Python applications use this function.

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service unavailability due to resource exhaustion from CPU/memory consumption during malicious expansion.

🟠

Likely Case

Performance degradation leading to increased latency, timeouts, or temporary service disruption.

🟢

If Mitigated

Minimal impact with proper input validation and rate limiting in place.

🌐 Internet-Facing: MEDIUM - Web applications processing user input through expandvars() could be targeted.
🏢 Internal Only: LOW - Requires specific code patterns and user input paths.

🎯 Exploit Status

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

Exploitation requires the application to pass user input to os.path.expandvars(). The vulnerability is in the expansion logic itself.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Fixed in CPython commits referenced in CVE

Vendor Advisory: https://github.com/python/cpython/security/advisories

Restart Required: Yes

Instructions:

1. Update Python to version containing fixes from referenced commits. 2. Restart affected Python applications. 3. Verify no regressions in expandvars() functionality.

🔧 Temporary Workarounds

Input Validation

all

Validate and sanitize user input before passing to os.path.expandvars()

Limit Expansion Depth

all

Implement custom wrapper that limits recursion depth in variable expansion

🧯 If You Can't Patch

  • Implement strict input validation for any data passed to os.path.expandvars()
  • Monitor system resources and implement rate limiting on affected endpoints

🔍 How to Verify

Check if Vulnerable:

Review code for usage of os.path.expandvars() with user-controlled input. Check Python version against patched commits.

Check Version:

python --version

Verify Fix Applied:

Test expandvars() with crafted input that previously caused performance issues. Verify normal operation.

📡 Detection & Monitoring

Log Indicators:

  • Unusual CPU spikes
  • Increased latency in expandvars() calls
  • Timeout errors in related functions

Network Indicators:

  • Increased response times from affected services

SIEM Query:

search for 'expandvars' in application logs with performance degradation patterns

🔗 References

📤 Share & Export