CVE-2009-5042

9.1 CRITICAL

📋 TL;DR

CVE-2009-5042 is a vulnerability in python-docutils where insecure temporary file handling allows local attackers to create or overwrite arbitrary files. This affects systems running vulnerable versions of python-docutils, particularly those where untrusted users can execute docutils commands or scripts that use docutils functionality.

💻 Affected Systems

Products:
  • python-docutils
Versions: Versions before 0.6
Operating Systems: Linux, Unix-like systems, Windows
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability exists when docutils tools (like rst2html.py) are executed with temporary file operations.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Local privilege escalation to root/system user, arbitrary file creation/modification leading to complete system compromise.

🟠

Likely Case

Local user gains unauthorized file access or modifies configuration files to elevate privileges.

🟢

If Mitigated

Limited impact with proper file permissions and user isolation in place.

🌐 Internet-Facing: LOW - This is primarily a local vulnerability requiring access to execute docutils commands.
🏢 Internal Only: MEDIUM - Risk exists in multi-user systems or shared hosting environments where untrusted users have shell access.

🎯 Exploit Status

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

Exploitation requires local access and ability to execute docutils commands. Race condition in temporary file handling can be exploited.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: python-docutils 0.6 and later

Vendor Advisory: https://security-tracker.debian.org/tracker/CVE-2009-5042

Restart Required: No

Instructions:

1. Update python-docutils to version 0.6 or later using your package manager. 2. For Debian/Ubuntu: sudo apt-get update && sudo apt-get install python-docutils. 3. For pip: pip install --upgrade docutils.

🔧 Temporary Workarounds

Restrict docutils execution

linux

Limit execution of docutils tools to trusted users only

chmod 750 /usr/bin/rst2*.py
chown root:trustedgroup /usr/bin/rst2*.py

Use secure temporary directory

linux

Set TMPDIR environment variable to a secure, user-isolated directory

export TMPDIR=/tmp/$USER
mkdir -p /tmp/$USER && chmod 700 /tmp/$USER

🧯 If You Can't Patch

  • Remove execute permissions from docutils scripts for untrusted users
  • Monitor for suspicious file operations in /tmp directories

🔍 How to Verify

Check if Vulnerable:

Check python-docutils version: python -c "import docutils; print(docutils.__version__)"

Check Version:

python -c "import docutils; print(docutils.__version__)" or dpkg -l python-docutils | grep ^ii

Verify Fix Applied:

Verify version is 0.6 or higher: python -c "import docutils; print('Vulnerable' if docutils.__version__ < '0.6' else 'Patched')"

📡 Detection & Monitoring

Log Indicators:

  • Failed file operations in /tmp
  • Unexpected docutils process execution by non-privileged users

Network Indicators:

  • Not applicable - local vulnerability

SIEM Query:

process.name:rst2* AND user.name:!root

🔗 References

📤 Share & Export