Skip to content

Shell scripts, CGI and socat glue (X1) ​

No hook needed

This package installs nothing and the hub proposes nothing for it. The kernel links these services exactly by itself. The page explains how, so you know what to expect in the hub.

A lot of A/D services are a shell script or a small binary behind a forking wrapper: socat TCP-LISTEN:…,fork EXEC:./service, ncat --exec, xinetd, tcpserver, or a CGI script behind a web server that forks per connection. Every connection then gets its own process tree, and that tree inherited exactly one connection. vulnboxd's sensor sees the fork/exec lineage and the inherited socket, so it links everything the tree does (spawned commands, files written and read, outgoing connections) to the connection without a runtime hook.

Covers ​

Versions
Shellsbash, dash, BusyBox ash, zsh, any POSIX sh. Also any program run the same way (Python, Perl, a C binary)
socat1.7 and 1.8: TCP-LISTEN:…,fork with EXEC: or SYSTEM:, with or without nofork, pty, pipes, stderr
ncat / netcatNmap ncat -lk --exec / --sh-exec, OpenBSD/traditional nc -e
inetd stylexinetd, inetd, ucspi tcpserver, systemd socket activation with Accept=yes
CGIBusyBox httpd, thttpd, Apache prefork mod_cgi (every server that forks per connection)

What the kernel already links: everything. Each connection is served by a process that inherited exactly one accepted socket, and everything it starts descends from it. This holds for the connection. With HTTP keep-alive behind a forking CGI server, each CGI run is its own child process, so a request is also exactly one process subtree.

Where it does not hold: a CGI script run by an event-loop web server (lighttpd, nginx + fcgiwrap, Caddy's CGI module, Apache's mod_cgid daemon) descends from a process that holds many connections at once. Lineage then proves only "some request of this server". These services need the web server's own request log (the proxy request log covers the outer hop), or a hook in a forking wrapper. vulnboxd records no guessed link in that case.

How it gets in ​

Nothing gets in. There is no proposal and no compose change. If the hub detects one of these services (socat, ncat, nc -e, xinetd, tcpserver or httpd in the Dockerfile CMD/ENTRYPOINT or the compose command, or a .sh entrypoint), it shows "kernel-linked, no hook needed".

What it records ​

No hook events. The sensor's kernel events and how it names and links them:

What happensWhat the sensor seesHow it's linked
socat/ncat/httpd accepts a connectionaccept4 in the listener processthe accepted socket's peer ip:port joins it to the external flow (through the proxy request log / docker-proxy socket pair)
it forks a child per connectionsched_process_fork: child pid, parent pidthe child inherited the accepted socket; after the fork the listener closes its copy, so the child is the connection-owning process
the child runs the servicesched_process_exec: the new process's argv (e.g. /bin/bash /srv/service.sh), with the exe path and cwdnamed after its argv in the Trace view and in the process tree; linked to the connection through the owning process
the service runs commandsfork/exec of descendants (cat flag.txt, sh -c …)process lineage: descendants of the connection-owning process
it reads or writes files, connects outopenat, connect, … in any descendantprocess lineage

What each wrapper's process tree looks like ​

The samples print what the service process itself can prove from /proc (see below). In short:

WrapperPer-connection processThe service's stdin/stdoutConnection-owning process
socat …,fork EXEC:svcsocat child, which forks and execs svca unix socketpair to the socat child (socat relays bytes)the socat child (svc's parent)
socat …,fork EXEC:svc,noforkthe socat child execs svc itselfthe accepted TCP socket, dup2ed onto 0 and 1svc itself
socat …,fork EXEC:svc,ptyas the first rowa ptythe socat child
ncat -lk --exec svcncat child, which forks and execs svcpipes to the ncat child (it relays)the ncat child
nc -e svc (traditional)nc execs svc after dup2the accepted TCP socketsvc itself
xinetd / inetd / tcpserverthe server forks and execs svcthe accepted TCP socket (dup2 onto 0, 1 and for inetd often 2)svc itself
BusyBox httpd CGIhttpd child per connection, forks the scriptpipes to the httpd childthe httpd child

The socket-onto-stdio pattern is expected here ​

dup2(socket, 0..2) followed by execve is the classic reverse/bind-shell pattern, and the sensor treats it as a high-signal event, with one exception. When the process doing it is the one that accepted the socket on a port the service declares (or descends from it, as with socat nofork, nc -e, inetd), and what it execs is the service's normal entrypoint, it is the service's own glue and not an alert. The alert stays for:

  • a socket from an outgoing connect put onto stdio (reverse shell);
  • a socket accepted on an undeclared port (bind shell / backdoor listener);
  • a service process that execs a shell or interpreter with the client socket on stdio, other than its declared entrypoint (e.g. a C service's system() running sh with fd 0 still the socket after an exploit).

Unix socketpairs and pipes on stdio (socat's default EXEC, ncat, CGI) never trigger it.

Context following ​

Process lineage. Every process descending from the connection-owning process belongs to that connection. A daemon the script starts (setsid, nohup … &, double fork) is still its descendant in the kernel's fork events, so it stays linked even after it is reparented to init.

Keep-alive is not a concern: inetd-style services serve one connection per process tree. Forking CGI servers start one script per request.

Known gaps ​

  • Event-loop web servers with CGI/FastCGI (lighttpd, nginx + fcgiwrap, mod_cgid): lineage is ambiguous (see Covers). No link is recorded beyond the server.
  • socat without fork (TCP-LISTEN:8080 alone) serves one connection and exits. It is linked the same way, but the service is down between restarts.
  • Pre-forked pools in shell (a script that accepts in a loop with socat … STDIO workers handing jobs to a long-running worker via a FIFO): the worker is not a descendant of the connection. It is linked only while it holds exactly one client socket (the "unambiguous ownership" rule), otherwise not at all.
  • Many connections in one script (bash coproc servers, while read multiplexers): use a forking wrapper.

Safety ​

Nothing is loaded into the service, so there is nothing to fail. The sensor only observes (eBPF tracepoints, read-only).

The samples in hooks/shell/x1/samples/ pin the expectations down. Each one runs a shell service behind a real wrapper, drives it with the shared native driver, and checks that:

  • the recording core sees no hook events at all (golden.events is empty);
  • the responses are byte-identical across the harness's events, chaos and baseline runs. Each response ends with what the service process can prove about its connection from /proc: what its stdin/stdout are, and how many connections to the service port its parent holds.
SampleWrapperService stdioParent holds
socat-execsocat TCP-LISTEN:8080,fork EXEC:handler.sha unix socket (socketpair)1 connection (the socat child)
socat-noforksocat …,fork EXEC:handler.sh,noforkthe TCP socket, local port 8080, dup2ed0 (the listener; the handler owns the socket)
ncat-execncat -lk --exec handler.shpipes1 connection (the ncat child)
busybox-cgiBusyBox httpd -f, CGI scriptspipes1 connection (the httpd child)

Results (x86_64): every sample events: 0 recorded event(s) match golden.events, and chaos and baseline byte-identical. There is no bench, because there is no hook to measure.

These are kernel facts the sensor (S2) will observe directly. The current harness checks hook events only, so the samples prove "no hook needed" and pin the process shapes. The privileged sensor run will add kernel-event golden checks for the same samples once S2 exists.

Turning it off ​

There is nothing to turn off. The sensor's kernel collection is controlled in vulnboxd's monitoring configuration, not per service.

Troubleshooting ​

  • A command run by the service shows no request link. Check the process tree in the hub. If the command's ancestor is the wrapper's per-connection child, it is linked. If the ancestor is the listener itself (socat without fork restarting, a daemon started at container start), it predates the connection.
  • A CGI service is not linked. Check which web server runs it. Only forking servers give exact links (see Known gaps).
  • A reverse-shell alert for the service's own socat. The service is listening on a port that is not declared in the service's compose file / vulnboxd service config, so the accept is not recognised as the service's. Declare the port.
  • Which links did a flow get? The hub shows each link's method: here kernel:lineage and kernel:inherited-socket, never hook:*.