heroui logo

Linux Possible Privilege Escalation via PYTHONPATH

Splunk Security Content

View Source
Summary
The Linux Possible Privilege Escalation via PYTHONPATH analytic detects the creation of a malicious shared object placed in a Python import path outside standard system library directories, used to abuse PYTHONPATH for local privilege escalation. In the described scenario, an attacker leverages vulnerabilities such as CVE-2024-48990 (NeedRestart) by placing a crafted importlib/__init__.so in a directory under attacker control and modifying PYTHONPATH so that a privileged process (e.g., NeedRestart running as root) loads the rogue module instead of the legitimate one, achieving code execution with elevated privileges. The rule monitors filesystem write events for importlib/__init__.so that do not originate from trusted system library paths (e.g., /lib, /lib64, /usr/lib, /usr/local/lib, and equivalents). When such a write is observed, the detection correlates file_path, file_name, user, destination, and process context to flag potential abuse. The implementation relies on data from Endpoint EDR telemetry (Endpoint.Filesystem) ingested via Splunk CIM normalization; the search uses a Linux-specific datamodel and a dedicated linux_possible_privilege_escalation_via_pythonpath_filter to reduce false positives. The rule includes drilldown searches to view results by user/destination and to surface risk events, and maps to MITRE techniques T1068 (Privilege Escalation) and T1574.007 (Hijack Execution Flow: Path Interception). A sample Linux test dataset is provided for validation. References emphasize the NeedRestart vulnerability and related analyses of python path hijacking.
Categories
  • Endpoint
  • Linux
Data Sources
  • File
  • Process
ATT&CK Techniques
  • T1068
  • T1574.007
Created: 2026-08-08