Skip to content

Local development with runtime hooks ​

The runtime hooks tell vulnboxd's sensor which request a syscall was made for. You don't need a vulnbox to work with them. On your own machine you can run a service with its hook, including the hooks that change the source (Rust, Go, C/C++, .NET, Dart, …), and see the events the sensor would see. You need no root, no eBPF and no sensor.

There are three ways to get a hook:

  • From your language's registry. Every hook is published under a name the team controls, and the published version is always the vulnboxd release. Use this when the service's build has network access.
  • The hook directory under your home. vulnboxctl hooks install-local installs the same files a vulnbox has in /usr/local/lib/vulnboxd/trace and prints the lines that use them. Use this for the compose-only hooks, which need only an environment variable and a mount.
  • Vendored. The hub proposes this on a vulnbox, for offline A/D build environments. The vendored files are the same release as the published packages.

A hook does nothing until a tracer attaches: on a vulnbox that is the sensor, on your machine it is vbxtrace watch.

The hook directory ​

The release archive has the hook directory in trace/, next to vulnboxctl and vbxtrace:

sh
curl -fsSL https://gitlab.com/nirvati-ug/ctf-garden/vulnboxd/-/releases/permalink/latest/downloads/vulnboxd-x86_64-unknown-linux-gnu.tar.gz | tar -xz
cd vulnboxd-x86_64-unknown-linux-gnu
./vulnboxctl hooks install-local            # → ~/.local/share/vulnboxd/trace
./vulnboxctl hooks install-local --dir ./trace-copy

The command checks the directory against its MANIFEST and replaces an older copy atomically. It then prints the compose lines for every compose-only hook, which are the same lines the hub proposes, with your path as the mount source:

yaml
services:
  app:
    volumes:
      - /home/you/.local/share/vulnboxd/trace:/opt/vbxtrace:ro
    environment:
      PYTHONPATH: /opt/vbxtrace/python     # or NODE_OPTIONS, RUBYOPT, PERL5OPT, JAVA_TOOL_OPTIONS, ...

It also prints the variables for running the service directly on your machine, without a container. For example, export PYTHONPATH=~/.local/share/vulnboxd/trace/python or export JAVA_TOOL_OPTIONS=-javaagent:~/.local/share/vulnboxd/trace/jvm/vbxtrace-agent.jar. The Python, Node, Bun, Deno, Ruby, Perl, JVM, .NET and BEAM hooks find the core relative to their own files. The C-based bindings (C/C++, Swift, Zig, …, the registry packages included) and Dart load the file named by VBXTRACE_LIB, else /opt/vbxtrace/libvbxtrace-<arch>.so. Use the line install-local prints for them:

sh
export VBXTRACE_LIB=~/.local/share/vulnboxd/trace/libvbxtrace-x86_64.so

They look in ~/.local/share/vulnboxd/trace (or $XDG_DATA_HOME/vulnboxd/trace) only with VBXTRACE_DEV=1, and only when that directory and the library belong to root or to you and nobody else can write them, so a library dropped into a writable home directory is never loaded by accident. A setuid or file-capability program ignores VBXTRACE_LIB, VBXTRACE_DEV and the home directory. The Lua and OpenResty hooks from the hook directory expect /opt/vbxtrace, so run those in a container, or use the LuaRocks package.

On a vulnbox, vulnboxctl install and vulnboxctl upgrade install the hook directory from the release into /usr/local/lib/vulnboxd/trace. They also install the sensor's eBPF objects into /usr/local/lib/vulnboxd/. A copy that a running container still has mounted is kept under trace.old/ until nothing uses it, so a service started before an upgrade never loses a file.

Watching the events: vbxtrace watch ​

sh
vbxtrace watch -- python3 app.py               # start a command under the tracer
vbxtrace watch -- node --require vbxtrace/register server.js
vbxtrace watch 12345                           # attach to a running process; Ctrl-C detaches
vbxtrace watch --out events.log -- ./service   # into a file, e.g. to compare with a golden file
text
vbxtrace: pid 4711: /home/you/.local/share/vulnboxd/trace/libvbxtrace-x86_64.so: 8/8 probe sites, 8 semaphores
request_begin pid=4711 tid=4790 ctx=1 local_port=8080 peer=127.0.0.1 peer_port=35588 request_index=0 protocol=http1
spawned pid=4711 tid=4790 ctx=1 child_pid=4791
request_end pid=4711 tid=4790 ctx=1 status=200

vbxtrace watch is a userspace USDT reader. It traces the process and every thread and child it starts, through forks and execs. It finds each loaded library or binary that has vbxtrace probes, which can be the core a binding loads or a Rust or C binary with the probes linked in. It then raises the probes' semaphores, which is what switches a hook on, and reads each probe's arguments at a breakpoint. The lines are in the same format as the sample services' recordings, so they compare with a golden.events file (vbxtrace-harness compare).

Libraries are caught when the dynamic linker loads them, before their first call. If you attach to a process later, you see the events from then on. A binding that checked enabled() only once at its start stays off; restart it under vbxtrace watch -- … instead. When it detaches, vbxtrace watch restores every probe site and semaphore, so the process runs on unchanged.

vbxtrace watch needs ptrace, so it only works on your own processes. To attach to a process that isn't your child, kernel.yama.ptrace_scope must be 0, or you need CAP_SYS_PTRACE. Starting a command works with scope 0 or 1 (the default on most distributions).

Registry packages ​

Every package is version for version the vulnboxd release, and so the same code as the hook directory and the vendored copies the hub proposes.

HookRegistryPackageInstall
P1–P7 PythonPyPIvbxtracepip install vbxtrace, then python -m vbxtrace app.py or import vbxtrace.auto
N1–N3 Node, N4 Bunnpmvbxtracenpm install vbxtrace, then node --require vbxtrace/register or bun --preload vbxtrace/bun
Y1 RubyRubyGemsvbxtrace (x86_64/aarch64, glibc and musl)gem install vbxtrace, then RUBYOPT=-rvbxtrace
H1, H2 PHPPackagistvulnboxd/vbxtracecomposer require vulnboxd/vbxtrace; the prebuilt extension is on the release page
L1 PerlCPANVbxTracecpanm VbxTrace, then PERL5OPT=-MVbxTrace
L3 LuaLuaRocksvbxtraceluarocks install vbxtrace, then lua -l vbxtrace app.lua
L2 OpenRestyOPMvulnboxd/lua-resty-vbxtraceopm get vulnboxd/lua-resty-vbxtrace (the core from the vbxtrace rock)
E1 Erlang / ElixirHexvbxtrace{:vbxtrace, "== <version>"} / {vbxtrace, "<version>"}, then vbxtrace:start()
J1–J4 JVMMaven Centralgarden.ctf.vulnboxd:vbxtrace-agentthe dist zip, unpacked, -javaagent:…/vbxtrace/jvm/vbxtrace-agent.jar
D1 .NETNuGetVbxTrace.Sources, VbxTrace.StartupHookdotnet add package VbxTrace.Sources, or the startup hook from the package
G2 Govanity importvulnboxd.ctf.garden/vbxtrace (+ /vbxgin, /vbxfiber, /vbxfasthttp, /vbxgrpc)go get vulnboxd.ctf.garden/vbxtrace@v<version> (Go 1.25+)
R1, R2 Rustcrates.iovbxtrace-hook (uses vbxtrace)cargo add vbxtrace-hook --features axum08
C1 C/C++release tarball, Conan, vcpkgvbxtrace-c-<version>.tar.gz, vbxtraceCMake FetchContent (targets vbxtrace::hook, vbxtrace::hook_static)
C3 SwiftSwift Package IndexVBXTrace (gitlab.com/nirvati-ug/ctf-garden/vbxtrace-swift).package(url: "https://gitlab.com/nirvati-ug/ctf-garden/vbxtrace-swift.git", exact: "<version>")
C3 Dartpub.devvbxtracedart pub add vbxtrace

The Go modules come straight from this repository: vulnboxd.ctf.garden/vbxtrace serves a go-import page for each module. Each page names the module's directory in the repository, which needs Go 1.25 or later. Each module's release tag is hooks/go/g2/vbxtrace[/<adapter>]/v<version>. Older Go toolchains can use the vendored copy from the hook directory (go/vbxtrace) instead.

Deno (N5) runs no TypeScript from node_modules: use the hook directory (deno run --preload ~/.local/share/vulnboxd/trace/deno/register.ts …). Zig, Nim, Crystal, D, Odin, V (C2), Kotlin/Native (C3) and Haskell, OCaml, Julia, R and Scala Native (C4) have no registry package. Copy their files from the hook directory (native/<language>), as the docs page for each one says.

For maintainers: building and publishing ​

sh
cargo run -p vbxtrace-harness -- hookdir        # target/vbxtrace-dist/hookdir/trace, both architectures
packaging/build.sh all                           # every package, each checked with its registry's dry run
packaging/build.sh pypi npm                      # or some of them
packaging/versions.sh set 1.1.0                  # before tagging a release

hookdir runs every package's build script and stages the core and every package's files. Building it twice gives the same MANIFEST. A packaging step whose tool isn't installed runs in a podman container. On a release tag, CI builds every package and publishes each one whose token is set as a masked, protected CI variable. Tokens are never stored in the repository.

VariableUsed for
CARGO_REGISTRY_TOKENcrates.io
GO_TAG_TOKENpushing the Go module tags (project access token, write_repository)
NPM_TOKENnpm (with provenance through the job's Sigstore ID token)
PYPI_TOKENPyPI
GEM_HOST_API_KEYRubyGems
NUGET_API_KEYNuGet
MAVEN_CENTRAL_USERNAME, MAVEN_CENTRAL_PASSWORD, GPG_PRIVATE_KEY, GPG_PASSPHRASEMaven Central (the garden.ctf.vulnboxd namespace must be verified)
HEX_API_KEYHex
PHP_MIRROR_TOKENpushing gitlab.com/nirvati-ug/ctf-garden/vbxtrace-php, which Packagist follows
PAUSE_USER, PAUSE_PASSWORDCPAN
LUAROCKS_API_KEY, OPM_GITHUB_TOKENLuaRocks, OPM (its account must be a GitHub user or organization)
PUB_CREDENTIALSpub.dev
SWIFT_MIRROR_TOKENpushing gitlab.com/nirvati-ug/ctf-garden/vbxtrace-swift, which the Swift Package Index follows
CONAN_REMOTE_URL, CONAN_LOGIN_USERNAME, CONAN_PASSWORDan optional Conan remote

CI ​

CI runs only on GitLab.com's hosted runners (saas-linux-<size>-amd64 and -arm64). Each job gets its own short-lived, privileged VM, so podman and Docker run inside the job's container, and a job may take at most 3 hours. Large and bigger runners, and medium arm64, need GitLab Premium. A fork on another plan can set the RUNNER_* CI/CD variables to other tags.

Cheap checks run on every pipeline. The expensive suites run by themselves on the default branch when what they test has changed, on release tags, on scheduled pipelines and when VBX_CI_FULL=1 is set. On merge requests and other branches you start them by hand, and they never block the pipeline.

JobRunnerNotes
fmt, reuse, helm, dashboards, hooks:python, hooks:node, pkg:*, upload, releasesmall
cheatsheets, vbxtrace, ui, docs, pages, sensor-ebpf, hookdirmedium
clippy, sensor-go, build, hook-checkslarge
docker-suiteslargedockerd and podman in the job's container, ClickHouse as a service
sensor-vm, sensor-go-vmlargeQEMU with KVM, or TCG emulation (see below)
testxlargeClickHouse as a service
e2exlargelike the VM tests, plus Docker's binaries and ClickHouse as a service
hook-samples (one job per language, native one per package)medium, large, or xlarge for C3podman in the job's container
hook-uringmediumio_uring for containers: checked first, see below
hookdir:arm64small arm64builds PHP's extension and BEAM's NIF for arm64, natively, for hookdir
test:arm64, hook-samples:arm64, hook-checks:arm64, sensor-vm:arm64large arm64arm64 is untested until these pass, so for now they can't fail a pipeline

Podman runs in quay.io/podman/stable. The VM tests and the Docker suites run in a Debian image with podman and dockerd added (ci/engines.sh). Either way, Docker Hub images are pulled through mirror.gcr.io.

Some things the runners may or may not have are checked when the job starts, and the job log says what it found:

  • KVM. ci/vm-test.sh runs the VM tests with KVM when /dev/kvm opens. Otherwise they run under QEMU's TCG emulation, which is many times slower, with a time budget below the 3 hours. A failure under TCG exits with code 3, which the job allows, so it shows as a warning and never as a pass. The arm64 VM job skips without KVM, also with exit code 3.
  • io_uring. ci/io-uring.sh checks whether a container may set up an io_uring. If it can't, the job skips with exit code 3, a warning.

On your own machine, VM_ACCEL=kvm or VM_ACCEL=tcg forces the VM tests' mode. The default is auto.

End-to-end test ​

tests/e2e/run.sh runs the whole system the way a team uses it. A QEMU VM (virtme-ng, the host's kernel) is the vulnbox: dockerd, a few compose services in git checkouts, vulnboxd with its proxy, the capture broker, the agent and the real eBPF sensor. The hub runs on the host against ClickHouse. A driver then plays checker and attacker and checks every step through the hub's API: flows and decoding, host-event links, hook proposals, alerts and a webhook, rule pushes, containers and shells, the database browser, rollback and bisect, access control. Nothing is loaded into the host's kernel.

sh
tests/e2e/run.sh                      # build, then run (about 12 minutes)
NO_BUILD=1 tests/e2e/run.sh           # run with what is already built
STEPS=flows,alerts tests/e2e/run.sh   # only these steps (and the ones they need)
HOLD=1 tests/e2e/run.sh               # keep the VM and the hub up afterwards, until target/e2e/release exists

It needs QEMU (with KVM, or TCG emulation as VM_ACCEL says), virtme-ng, a static busybox, podman, the eBPF toolchain, Docker's binaries (dockerd, containerd, runc, the compose plugin), tcpdump and git. VNG= and BUSYBOX= point at virtme-ng and a static busybox when they are not on the PATH, as for the sensor's VM tests. E2E_CLICKHOUSE= names the ClickHouse (default $HUB_TEST_CLICKHOUSE, or http://hub:hub@127.0.0.1:18123); the run uses a database of its own and drops it afterwards. The summary and the hub's and the VM's logs are in target/e2e (OUT= for another directory; one run per directory at a time).