CVE-2019-16729

7.8 HIGH

📋 TL;DR

CVE-2019-16729 is a privilege escalation vulnerability in pam-python that allows local users to gain root privileges by manipulating Python environment variables. This affects systems using pam-python for authentication with vulnerable versions. The vulnerability stems from improper handling of Python's default environment variables in PAM modules.

💻 Affected Systems

Products:
  • pam-python
Versions: All versions before 1.0.7-1
Operating Systems: Linux distributions using pam-python (Debian, Ubuntu, SUSE, etc.)
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects systems where pam-python is installed and configured in PAM authentication stack. Not all Linux systems use pam-python by default.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Local attacker gains full root privileges on the system, enabling complete system compromise, data theft, and persistence.

🟠

Likely Case

Local user with shell access escalates to root to install malware, modify system configurations, or access sensitive data.

🟢

If Mitigated

Attack fails due to proper access controls, SELinux/apparmor restrictions, or lack of local user accounts.

🌐 Internet-Facing: LOW - This is a local privilege escalation requiring existing local access.
🏢 Internal Only: HIGH - Any internal user with shell access could potentially exploit this to gain root privileges.

🎯 Exploit Status

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

Exploit requires local user access and knowledge of the system's PAM configuration. Proof of concept code is available in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.0.7-1 and later

Vendor Advisory: https://usn.ubuntu.com/4552-1/

Restart Required: No

Instructions:

1. Update pam-python package: sudo apt update && sudo apt upgrade pam-python (Debian/Ubuntu) or use your distribution's package manager. 2. Verify version is 1.0.7-1 or higher. 3. No service restart required, but PAM modules will use new version on next authentication.

🔧 Temporary Workarounds

Remove pam-python from PAM configuration

linux

Temporarily disable pam-python module from PAM authentication stack if not essential

sudo sed -i '/pam_python.so/d' /etc/pam.d/*
sudo systemctl restart systemd-logind

Restrict Python environment variables

linux

Set restrictive environment variables for PAM Python execution

sudo echo 'PYTHONPATH=' >> /etc/environment
sudo echo 'PYTHONHOME=' >> /etc/environment

🧯 If You Can't Patch

  • Remove local user accounts that are not strictly necessary
  • Implement strict access controls and monitor for privilege escalation attempts

🔍 How to Verify

Check if Vulnerable:

Check pam-python version: dpkg -l | grep pam-python (Debian/Ubuntu) or rpm -q pam-python (RHEL/SUSE). If version is earlier than 1.0.7-1, system is vulnerable.

Check Version:

dpkg -l | grep pam-python || rpm -q pam-python || apt-cache policy pam-python

Verify Fix Applied:

Verify pam-python version is 1.0.7-1 or higher: dpkg -l | grep pam-python should show version 1.0.7-1 or later.

📡 Detection & Monitoring

Log Indicators:

  • Unusual PAM authentication failures
  • Unexpected Python module loads in PAM context
  • Sudden privilege changes for local users

Network Indicators:

  • None - this is local exploitation only

SIEM Query:

source="auth.log" AND ("pam_python" OR "python") AND ("failure" OR "error")

🔗 References

📤 Share & Export