Nsenter to PID Namespace via Auditd
Description
Detects nsenter executions that target PID with a namespace target flag, a pattern commonly used to attach to the host init namespace from a container or session and run with host context.
Query · kuery
host.os.type:linux and event.category:process and event.action:(exec or executed) and (process.name:nsenter or process.args:nsenter) and process.args:( (-t or --target*) and not --net=/run/netns/* and not (--assertion and snap) and not (is-active and snap.*) and not (-anp and netstat) )
Implementation guide
Deploy the Auditd Manager integration on Linux hosts that should emit process execution telemetry (Fleet, Integrations, Auditd Manager, attach to an agent policy).
Ensure syscall rules capture execve for utilities such as nsenter so event.category process and event.action executed populate with process.name and process.args.
See https://docs.elastic.co/integrations/auditd_manager for integration details.
Known false positives
- Platform engineers may nsenter into PID 1 namespaces during deep node debugging; correlate with tickets and bastion sessions before escalating.
Analyst notes
Investigating Nsenter to PID Namespace via Auditd
Review process.args for the full nsenter invocation (target PID, mount, UTS, IPC, net, user namespaces), parent process, user identity, and host. PID targeting is a strong escape or host-administration signal when unexpected for the actor.
Possible investigation steps
- Confirm whether the session originated from a container, SSH session, or automation agent.
- Pivot on the same host for subsequent writes under /etc, docker.sock access, or new systemd units.
False positive analysis
- Some CNI or snap workflows can resemble nsenter; rely on the built-in exclusions first, then tune by parent command or service account.
Response and remediation
- If malicious, isolate the host, revoke credentials, inspect for persistence, and re-image if integrity cannot be proven.