Hook cheat sheet: Odin
How to add a vulnboxd runtime hook to a Odin service by hand. Find your setup in the table, then follow its block.
- Without source access: only the compose file changes; redeploy. With source access: you change the code or Dockerfile and rebuild.
- Hub automation says how much the hub's proposals do for you. Fully: approve the proposal in the hub; the block is the fallback when it failed. With conditions: the same, when the conditions listed hold. Partly: the hub pushes the compose part, the rest is yours. Not at all: everything is by hand.
/usr/local/lib/vulnboxd/traceis the hook directory vulnboxd installs on the vulnbox. Compose snippets mount it read-only at/opt/vbxtracein the container.- How to check that the hook works and undo it is at the end of the page.
- Runtime hooks explains what a hook does.
Odin
| Setup | Use this when | Change | Hub automation |
|---|---|---|---|
| Odin: session tracing for core:net servers | Started with odin build or odin run | source, rebuild | partly |
With source access
These change the service's code or Dockerfile, then it is rebuilt.
Odin: session tracing for core:net servers
- Use this when: Odin service started with
odin buildorodin run. - Hub automation: partly. The hub pushes the compose lines; the source change is yours.
- Check and undo: hook mounted into the container
Vendors vbxtrace.odin and C1's vbxhook into vbxtrace/, builds vbxhook.a in the Dockerfile, and wraps each accepted connection (raw session) or request in vbx.begin / vbx.end; vbx.process_start / vbx.open / vbx.dial_tcp_endpoint link child processes, files and outgoing connections. Thread-per-connection servers are already linked by the kernel: the hook adds session and keep-alive request boundaries. Needs the read-only hook mount at /opt/vbxtrace.
1. Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro2. Source change, then rebuild:
- copy
/usr/local/lib/vulnboxd/trace/native/odin/vbxtrace.odininto./vbxtrace/, andnative/c/vbxhook.h,native/c/vbxhook.candinclude/vbxtrace.htoo Dockerfile, beforeodin build:RUN cc -O2 -c -Ivbxtrace -o /tmp/vbxhook.o vbxtrace/vbxhook.c && ar rcs vbxtrace/vbxhook.a /tmp/vbxhook.oimport vbx "vbxtrace"; per accepted connection:ctx := vbx.begin(client, 0, vbx.PROTO_RAW)/defer vbx.end(ctx, 0)(HTTP: onebegin/endper request with the connection's request counter andvbx.PROTO_HTTP1)- optional:
vbx.process_start(ctx, ...),vbx.open(ctx, ...),vbx.dial_tcp_endpoint(ctx, ...),vbx.spawn_thread(ctx, ...) - add the read-only mount of
/usr/local/lib/vulnboxd/traceat/opt/vbxtraceto the service indocker-compose.yml
Example change on a sample service (hooks/native/c2/proposals/odin-tcp.diff):
Adds vulnboxd session tracing to a thread-per-connection core:net service in Odin. Vendor first (not shown):
vbxtrace/vbxtrace.odin <- /usr/local/lib/vulnboxd/trace/native/odin/vbxtrace.odin
vbxtrace/vbxhook.h, vbxhook.c <- /usr/local/lib/vulnboxd/trace/native/c/
vbxtrace/vbxtrace.h <- /usr/local/lib/vulnboxd/trace/include/vbxtrace.h
diff --git a/docker-compose.yml b/docker-compose.yml
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,3 +3,5 @@
build: .
ports:
- "8080:8080"
+ volumes:
+ - /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
diff --git a/Dockerfile b/Dockerfile
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,5 +3,7 @@
RUN mkdir -p /opt/odin && curl -fsSL https://github.com/odin-lang/Odin/releases/download/dev-2026-10/odin-linux-amd64-dev-2026-10.tar.gz | tar -xz -C /opt/odin --strip-components=1
WORKDIR /app
COPY . .
+# vulnboxd request tracing: vbxhook.c (vendored in vbxtrace/) as the archive vbxtrace.odin imports
+RUN cc -O2 -c -Ivbxtrace -o /tmp/vbxhook.o vbxtrace/vbxhook.c && ar rcs vbxtrace/vbxhook.a /tmp/vbxhook.o
RUN /opt/odin/odin build . -o:speed -out:/app/logger
CMD ["/app/logger"]
diff --git a/main.odin b/main.odin
--- a/main.odin
+++ b/main.odin
@@ -3,12 +3,15 @@
import "core:net"
import "core:os"
import "core:thread"
+import vbx "vbxtrace" // vulnboxd request tracing
handle :: proc(client: net.TCP_Socket) {
defer net.close(client)
+ ctx := vbx.begin(client, 0, vbx.PROTO_RAW)
+ defer vbx.end(ctx, 0)
buf: [256]byte
n, _ := net.recv_tcp(client, buf[:])
- f, err := os.open("/data/log", {.Write, .Create, .Append})
+ f, err := vbx.open(ctx, "/data/log", {.Write, .Create, .Append})
if err == nil {
os.write(f, buf[:n])
os.close(f)
@@ -17,6 +20,7 @@
}
main :: proc() {
+ vbx.init()
ep, _ := net.parse_endpoint("0.0.0.0:9000")
l, _ := net.listen_tcp(ep)
for {Exact detection rules
Package C2 (Zig, Nim, Crystal, D, Odin, V), proposal C2:odin, defined in hooks/native/c2/proposals/odin.toml.
- Image matches (regex):
odin - Command matches (regex):
\bodin\s+(build|run)\b - Files:
*.odin,src/*.odin,ols.json
Check that it works, and undo
Each block links the variant it needs.
Hook mounted into the container
Check: After the redeploy, this lists the processes that loaded the hook (empty: it is not loaded):
docker compose exec app sh -c 'grep -l vbxtrace /proc/[0-9]*/maps'The hub's Trace tab then shows links whose method starts with hook:.
Undo: Set VBXTRACE: "0" in the service's environment and restart it, or revert the commit (the hub's proposal screen has a revert per container). Remove the mount of /opt/vbxtrace only together with what loads from it: a runtime told to preload a missing file may refuse to start.