Proc Memory
Adversaries may inject malicious code into processes via the /proc filesystem in order to evade process-based defenses as well as possibly elevate privileges. Proc memory injection involves enumerating the memory of a process via the /proc filesystem (/proc/[pid]) then crafting a return-oriented programming (ROP) payload with available gadgets/instructions. Each running process has its own directory, which includes memory mappings. Proc memory injection is commonly performed by overwriting the target processes' stack using memory mappings provided by the /proc filesystem. This information can be used to enumerate offsets (including the stack) and gadgets otherwise hidden by ASLR. Once enumerated, the target processes' memory map within /proc/[pid]/maps can be overwritten using dd.
// Detect /proc/[pid]/mem and /proc/[pid]/maps access for injection
Syslog
| where TimeGenerated > ago(24h)
| where SyslogMessage has_any ("/proc/") and SyslogMessage has_any ("mem", "maps", "syscall")
| where SyslogMessage !has "self" // exclude /proc/self/ access (legitimate)
| where SyslogMessage !has "gdb" and SyslogMessage !has "strace"
| extend ProcAccess = extract(@"/proc/(\d+)/(mem|maps|syscall)", 0, SyslogMessage)
| where isnotempty(ProcAccess)
| project TimeGenerated, Computer, SyslogMessage, ProcAccess, Facility, SeverityLevel
| sort by TimeGenerated desc Data Sources
Required Tables
False Positives
- System monitoring tools (top, htop, ps) reading /proc/[pid]/maps for memory statistics
- Container orchestration tools reading /proc filesystem for resource accounting
- Performance profiling tools (perf, valgrind) reading process memory maps
- Security scanning tools analyzing process memory layout for vulnerability assessment
References (5)
- https://attack.mitre.org/techniques/T1055/009/
- http://hick.org/code/skape/papers/needle.txt
- https://blog.gdssecurity.com/labs/2017/9/5/linux-based-inter-process-code-injection-without-ptrace2.html
- http://man7.org/linux/man-pages/man1/dd.1.html
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1055.009/T1055.009.md
Unlock Pro Content
Get the full detection package for T1055.009 including response playbook, investigation guide, and atomic red team tests.