Detection rules › Splunk
Linux Possible Privilege Escalation via PYTHONPATH
The following analytic detects the creation of a malicious shared object at a Python importlib path outside the standard system library directories, a technique used to abuse PYTHONPATH for local privilege escalation. Attackers exploiting vulnerabilities such as the 2024 NeedRestart flaw (CVE-2024-48990) plant a crafted importlib/init.so in an attacker-controlled directory, then manipulate the PYTHONPATH environment variable so that a privileged process, such as NeedRestart running as root, loads the rogue module instead of the legitimate one, achieving code execution with elevated privileges. The detection monitors for file writes matching the importlib/init.so pattern that do not originate from expected system library paths.
Known false positives
- Legitimate Python developers or system administrators may modify PYTHONPATH for testing or application configuration purposes. Filter based on known development environments and trusted user activity.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | |
| Privilege Escalation | |
| Stealth |
Telemetry coverage
| Platform | Record / event type |
|---|---|
| Linux | Event ID 11: File created |
Rule body
name: Linux Possible Privilege Escalation via PYTHONPATH
id: 5edda575-409a-4820-a048-5780796a181e
version: 1
creation_date: '2026-07-08'
modification_date: '2026-07-08'
author: Raven Tait, Splunk
status: production
type: TTP
description: |-
The following analytic detects the creation of a malicious shared object at a Python importlib path outside the standard system library directories, a technique used to abuse PYTHONPATH for local privilege escalation.
Attackers exploiting vulnerabilities such as the 2024 NeedRestart flaw (CVE-2024-48990) plant a crafted importlib/__init__.so in an attacker-controlled directory, then manipulate the PYTHONPATH environment variable so that a privileged process, such as NeedRestart running as root, loads the rogue module instead of the legitimate one, achieving code execution with elevated privileges.
The detection monitors for file writes matching the importlib/__init__.so pattern that do not originate from expected system library paths.
data_source:
- Sysmon for Linux EventID 11
search: |-
| tstats `security_content_summariesonly`
count min(_time) as firstTime
max(_time) as lastTime
from datamodel=Endpoint.Filesystem where
Filesystem.file_path="*/importlib/__init__.so*"
NOT Filesystem.file_path IN (
"/lib/*",
"/lib64/*",
"/usr/lib/*",
"/usr/lib64/*",
"/usr/local/lib/*",
"/usr/local/lib64/*"
)
by Filesystem.file_path Filesystem.file_name Filesystem.user Filesystem.dest
Filesystem.process_guid Filesystem.process_id
| `drop_dm_object_name(Filesystem)`
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `linux_possible_privilege_escalation_via_pythonpath_filter`
how_to_implement: |-
The detection is based on data that originates from Endpoint Detection and Response (EDR) agents. These agents are designed to provide security-related telemetry from the endpoints where the agent is installed. To implement this search, you must ingest logs that contain file creation events including the file path and user context. These logs must be processed using the appropriate Splunk Technology Add-ons that are specific to the EDR product. The logs must also be mapped to the `Filesystem` node of the `Endpoint` data model. Use the Splunk Common Information Model (CIM) to normalize the field names and speed up the data modeling process.
known_false_positives: |-
Legitimate Python developers or system administrators may modify PYTHONPATH for testing or application configuration purposes. Filter based on known development environments and trusted user activity.
references:
- https://www.bleepingcomputer.com/news/security/ubuntu-linux-impacted-by-decade-old-needrestart-flaw-that-gives-root/
- https://www.qualys.com/2024/11/19/needrestart/needrestart.txt
finding:
title: Possible Privilege Escalation via PYTHONPATH via [$file_name$] on [$dest$]
entity:
field: dest
type: system
score: 50
threat_objects:
- field: file_name
type: file_name
analytic_story:
- Linux Privilege Escalation
- Linux Post-Exploitation
- Linux Persistence Techniques
asset_type: Endpoint
cve:
- CVE-2024-48990
mitre_attack_id:
- T1068
- T1574.007
product:
- Splunk Enterprise
- Splunk Enterprise Security
- Splunk Cloud
category: endpoint
security_domain: endpoint
Stages and Predicates
Stage 1: tstats
| tstats `security_content_summariesonly`
count min(_time) as firstTime
max(_time) as lastTime
from datamodel=Endpoint.Filesystem where
Filesystem.file_path="*/importlib/__init__.so*"
NOT Filesystem.file_path IN (
"/lib/*",
"/lib64/*",
"/usr/lib/*",
"/usr/lib64/*",
"/usr/local/lib/*",
"/usr/local/lib64/*"
)
by Filesystem.file_path Filesystem.file_name Filesystem.user Filesystem.dest
Filesystem.process_guid Filesystem.process_id
Stage 2: search
| `drop_dm_object_name(Filesystem)`
Stage 3: search
| `security_content_ctime(firstTime)`
Stage 4: search
| `security_content_ctime(lastTime)`
Stage 5: search
| `linux_possible_privilege_escalation_via_pythonpath_filter`
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
Filesystem.file_path | in | "/lib/*", "/lib64/*", "/usr/lib/*", "/usr/lib64/*", "/usr/local/lib/*", "/usr/local/lib64/*" | excludes:Filesystem.file_path |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
Filesystem.file_path | eq |
| field:"TargetFilename" kind:eq |