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 | |
|---|---|
| Shells | bash, dash, BusyBox ash, zsh, any POSIX sh. Also any program run the same way (Python, Perl, a C binary) |
| socat | 1.7 and 1.8: TCP-LISTEN:…,fork with EXEC: or SYSTEM:, with or without nofork, pty, pipes, stderr |
| ncat / netcat | Nmap ncat -lk --exec / --sh-exec, OpenBSD/traditional nc -e |
| inetd style | xinetd, inetd, ucspi tcpserver, systemd socket activation with Accept=yes |
| CGI | BusyBox 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 happens | What the sensor sees | How it's linked |
|---|---|---|
| socat/ncat/httpd accepts a connection | accept4 in the listener process | the 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 connection | sched_process_fork: child pid, parent pid | the 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 service | sched_process_exec: the new process's argv (e.g. /bin/bash /srv/service.sh), with the exe path and cwd | named after its argv in the Trace view and in the process tree; linked to the connection through the owning process |
| the service runs commands | fork/exec of descendants (cat flag.txt, sh -c …) | process lineage: descendants of the connection-owning process |
| it reads or writes files, connects out | openat, connect, … in any descendant | process 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:
| Wrapper | Per-connection process | The service's stdin/stdout | Connection-owning process |
|---|---|---|---|
socat …,fork EXEC:svc | socat child, which forks and execs svc | a unix socketpair to the socat child (socat relays bytes) | the socat child (svc's parent) |
socat …,fork EXEC:svc,nofork | the socat child execs svc itself | the accepted TCP socket, dup2ed onto 0 and 1 | svc itself |
socat …,fork EXEC:svc,pty | as the first row | a pty | the socat child |
ncat -lk --exec svc | ncat child, which forks and execs svc | pipes to the ncat child (it relays) | the ncat child |
nc -e svc (traditional) | nc execs svc after dup2 | the accepted TCP socket | svc itself |
xinetd / inetd / tcpserver | the server forks and execs svc | the accepted TCP socket (dup2 onto 0, 1 and for inetd often 2) | svc itself |
BusyBox httpd CGI | httpd child per connection, forks the script | pipes to the httpd child | the 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
connectput 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()runningshwith 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:8080alone) 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 … STDIOworkers 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
coprocservers,while readmultiplexers): 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.eventsis 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.
| Sample | Wrapper | Service stdio | Parent holds |
|---|---|---|---|
socat-exec | socat TCP-LISTEN:8080,fork EXEC:handler.sh | a unix socket (socketpair) | 1 connection (the socat child) |
socat-nofork | socat …,fork EXEC:handler.sh,nofork | the TCP socket, local port 8080, dup2ed | 0 (the listener; the handler owns the socket) |
ncat-exec | ncat -lk --exec handler.sh | pipes | 1 connection (the ncat child) |
busybox-cgi | BusyBox httpd -f, CGI scripts | pipes | 1 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
forkrestarting, 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:lineageandkernel:inherited-socket, neverhook:*.