T1055.008 Elastic Security · Elastic

Detect Ptrace System Calls in Elastic Security

Adversaries may inject malicious code into processes via ptrace (process trace) system calls in order to evade process-based defenses as well as possibly elevate privileges. Ptrace system call injection involves attaching to and modifying a running process. The ptrace system call enables a debugging process to observe and control another process (and each individual thread), including changing memory and register values. Ptrace system call injection is commonly performed by writing arbitrary code into a running process (ex: malloc) then invoking that memory with PTRACE_SETREGS to set the register containing the next instruction to execute. Ptrace system call injection can also be done with PTRACE_POKETEXT/PTRACE_POKEDATA, which copy data to a specific address in the target processes' memory.

MITRE ATT&CK

Tactic
Defense Evasion Privilege Escalation
Technique
T1055 Process Injection
Sub-technique
T1055.008 Ptrace System Calls
Canonical reference
https://attack.mitre.org/techniques/T1055/008/

Elastic Detection Query

Elastic Security (Elastic)
eql
process where host.os.type == "linux"
  and event.module == "auditd"
  and auditd.data.syscall == "ptrace"
  and auditd.data.a0 in ("4", "5", "d", "10", "13", "16", "19", "25")
  and not process.name in ("gdb", "strace", "ltrace", "valgrind", "perf", "dockerd", "containerd", "runc", "java", "py-spy")
high severity high confidence

Detects ptrace system calls on Linux with write/modify-capable request types (PTRACE_POKETEXT=0x4, PTRACE_POKEDATA=0x5, PTRACE_SETREGS=0xd/0x13, PTRACE_ATTACH=0x10/0x16, PTRACE_SEIZE=0x19/0x25) from non-legitimate debugger processes. Uses Elastic Auditd integration which resolves syscall numbers and captures the a0 argument in hex. Covers the primary injection primitives that allow an attacker to write shellcode into or redirect execution within a target process.

Data Sources

Elastic Agent with Auditd integration (logs-auditd.log-*)Auditbeat with auditd module configured for syscall auditingLinux auditd with -a always,exit -F arch=b64 -S ptrace -k ptrace_injection rule

Required Tables

auditd-*.ds-logs-auditd.log-*.ds-logs-system.syslog-*

False Positives & Tuning

  • Legitimate debuggers or IDE debug adapters installed to non-standard paths not matched by name exclusions (e.g., lldb, delve, rr, code-server debug shims)
  • JVM-based APM agents using the Attach API (com.sun.tools.attach) which internally uses ptrace on older kernel versions
  • Third-party EDR or AV agents that use ptrace for process introspection, memory scanning, or behavioral monitoring
Download portable Sigma rule (.yml)

Other platforms for T1055.008


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Ptrace Attachment via strace

    Expected signal: auditd: SYSCALL type with syscall=101, a0=16 (PTRACE_ATTACH), a1=<target_pid>, exe=/usr/bin/strace. /proc/<target_pid>/status will show TracerPid=<strace_pid> while attached.

  2. Test 2Ptrace Memory Read via /proc/pid/mem

    Expected signal: auditd: open() syscall on /proc/<pid>/maps. If ptrace is used: SYSCALL with syscall=101. The /proc/pid/maps read itself may be logged by auditd file access rules.

  3. Test 3Check ptrace_scope Kernel Setting

    Expected signal: No security telemetry — this is a configuration check. The output shows the current ptrace restriction level.

Unlock Pro Content

Get the full detection package for T1055.008 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections