Potential Privilege Escalation via Python Exploit
Description
Detects a UID change event to 0 (root) where the responsible process is a Python interpreter running from a user- or world-writeable working directory and the parent process is non-root. This may be indicative of a local privilege escalation exploit executed via Python.
Query · eql
process where event.type == "change" and event.action == "uid_change" and
user.id == 0 and process.parent.user.id != 0 and process.parent.group.id != 0 and
process.name like "python*" and process.args like "*.py" and
process.working_directory like ("/tmp*", "/dev/shm*", "/var/tmp*", "/home/*", "/run/user*", "/var/run/user*") and
process.parent.working_directory like ("/tmp*", "/dev/shm*", "/var/tmp*", "/home/*", "/run/user*", "/var/run/user*") and
not (
process.interactive == false or
process.args like ("/usr/lib/linuxmint/mintUpdate/mintUpdate.py", "/home/*/.ansible/tmp/ansible-tmp-*.py") or
process.executable like (
"/sw/eb/sw/Python/*-GCCcore-*/bin/python*", "/home/*/*/anaconda3/envs/*/bin/python*", "/scratch/*/python*",
"/home/*/.local/share/uv/python/cpython-*-linux-x86_64-gnu/bin/python*"
) or
(
process.working_directory like "/home/*/openmc/atr-model" and
process.parent.executable like "/scratch/*/.conda/envs/openmc-env/bin/python*" and
process.command_line == "python core_model.py"
) or
process.parent.args like ("/home/agent/Claude/Project/Patches/venv/bin/python3*", "/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py")
)