Pseudoterminal (PTY) Creation from Suspicious Executable
Description
This rule detects the creation of the /dev/ptmx pseudoterminal device by executables located in common temporary or shared memory directories such as /tmp/, /var/tmp/, or /dev/shm/. While pseudoterminal creation is legitimate for interactive terminal sessions, malware and post-exploitation tools frequently allocate PTYs to spawn interactive shells (e.g., reverse shells) or evade detection. The use of temporary directories for staging or executing payloads is a common tactic in Linux-based attacks, making this behavior highly suspicious.
Query · eql
sequence by process.entity_id with maxspan=10s
[process where event.type == "start" and event.action == "exec" and
process.executable like ("/dev/shm/*", "/tmp/*", "/var/tmp/*") and not (
process.executable like (
"/tmp/ubuntu-release-upgrader-*/jammy", "/tmp/baum/easybuild/*", "/tmp/thangha/easybuild/LLVM/*/bin/*",
"/tmp/thangha/easybuild/LLVM/*/tools/*", "/tmp/u.*/easybuild/LLVM/*", "/tmp/*-vscode/.vscode-server/bin/*/node",
"/tmp/sshpass"
) or
process.working_directory like (
"/scratch/*", "/tmp/ubuntu-release-upgrader-*", "/tmp/newroot/*",
"/tmp/vscode-cli-*", "/tmp/.mount_*", "/tmp/cmdickens/easybuild/*"
) or
process.parent.executable like ("/tmp/*server/node", "/tmp/cursor-server-cache/bin/linux-x64/*/node", "/tmp/.tmp*/.vscode-server/bin/*/node")
)]
[file where event.type == "creation" and file.path == "/dev/ptmx"]