Linux Auditd SOCK RAW EAFNOSUPPORT From User Writable Path
Description
The following analytic detects a process executing from a user-writable directory calling socket() with SOCK_RAW (a1=3) and receiving EAFNOSUPPORT (exit=-97, errno 97). This is the kernel trigger for vhost-vsock class privilege escalation exploits. When socket() is called with an unregistered address family and SOCK_RAW, the kernel calls request_module() to attempt to load a matching protocol module. In vulnerable kernels, this triggers a stale IOTLB metadata cache access path that allows an unprivileged user to write an arbitrary value to modprobe_path. The specific address family number varies by kernel and exploit variant (AF 41, 42, or any unregistered AF).
Query · spl
`linux_auditd`
type=SYSCALL
key=sock_raw_eafnosupport
success=no
exit="-97"
a1=3
exe IN (
"/dev/shm/*",
"/home/*",
"/run/user/*",
"/tmp/*",
"/var/tmp/*"
)
| rename host as dest
| stats count min(_time) as firstTime
max(_time) as lastTime
values(exe) as process_path
values(a0) as address_family
values(pid) as pid
values(ppid) as ppid
BY auid uid dest ses
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `linux_auditd_sock_raw_eafnosupport_from_user_writable_path_filter`
Implementation guide
This detection requires auditd rules to capture failed socket() calls. Add the following rule to /etc/audit/rules.d/audit.rules to capture SOCK_RAW failures:
-a always,exit -F arch=b64 -S socket -F a1=3 -F success=0 -F auid>=1000 -F auid!=unset -k sock_raw_eafnosupport
-a always,exit -F arch=b32 -S socket -F a1=3 -F success=0 -F auid>=1000 -F auid!=unset -k sock_raw_eafnosupport
These logs should be ingested and processed using the Splunk Add-on for Unix and Linux (https://splunkbase.splunk.com/app/833).
Known false positives
- Legitimate processes almost never open a SOCK_RAW socket with an unregistered address family. The EAFNOSUPPORT error on a raw socket from a non-system path has no benign use case outside of socket fuzzing or explicit error-handling tests
Analyst notes
Known false positives: Legitimate processes almost never open a SOCK_RAW socket with an unregistered address family. The EAFNOSUPPORT error on a raw socket from a non-system path has no benign use case outside of socket fuzzing or explicit error-handling tests