CVE-2023-49797

8.8 HIGH

📋 TL;DR

This vulnerability allows an unprivileged attacker to trick a PyInstaller-built application running with elevated privileges into deleting arbitrary files they shouldn't have access to. The attack exploits a race condition or directory junction weakness during temporary file cleanup. Users are affected if they run PyInstaller applications containing matplotlib or win32com with elevated privileges and have unprotected temporary directories.

💻 Affected Systems

Products:
  • PyInstaller
Versions: All versions before 5.13.1
Operating Systems: Windows, Linux
Default Config Vulnerable: ✅ No
Notes: Requires specific conditions: PyInstaller app with matplotlib/win32com, elevated privileges, unprotected TEMP/TMP directories. Python 3.7.x or earlier vulnerable to directory junction attacks.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Privilege escalation leading to deletion of critical system files, potential system compromise, or denial of service.

🟠

Likely Case

Unauthorized deletion of user or application files, potentially causing data loss or application disruption.

🟢

If Mitigated

Limited to deletion of files within user's own permissions if applications run with standard privileges.

🌐 Internet-Facing: LOW - Requires local access and specific application execution conditions.
🏢 Internal Only: MEDIUM - Internal users with local access could exploit if conditions are met.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: HIGH

Exploitation requires precise timing for race condition attacks (TOCTOU) or specific Python version for directory junction attacks.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: pyinstaller >= 5.13.1

Vendor Advisory: https://github.com/pyinstaller/pyinstaller/security/advisories/GHSA-9w2p-rh8c-v9g5

Restart Required: Yes

Instructions:

1. Upgrade PyInstaller: pip install --upgrade pyinstaller>=5.13.1
2. Rebuild affected applications with updated PyInstaller
3. Redeploy rebuilt applications

🔧 Temporary Workarounds

Secure temporary directories

all

Ensure TEMP/TMP environment variables point to user-specific, protected directories

On Windows: set TMP=%USERPROFILE%\AppData\Local\Temp
On Linux: export TMP=/tmp/$(whoami)

Run with minimal privileges

all

Avoid running PyInstaller applications with elevated/admin privileges

🧯 If You Can't Patch

  • Run applications with standard user privileges only
  • Ensure TEMP/TMP directories are user-specific and protected with proper permissions

🔍 How to Verify

Check if Vulnerable:

Check PyInstaller version: pip show pyinstaller | grep Version
Check if applications contain matplotlib or win32com and run with elevated privileges

Check Version:

pip show pyinstaller | grep Version

Verify Fix Applied:

Verify PyInstaller version is 5.13.1 or higher: pip show pyinstaller | grep Version
Rebuild applications with updated version

📡 Detection & Monitoring

Log Indicators:

  • Unexpected file deletion events in system logs
  • Access denied errors for privileged file operations

Network Indicators:

  • None - local exploitation only

SIEM Query:

EventID 4663 (File deletion) with elevated privilege context on systems running PyInstaller applications

🔗 References

📤 Share & Export