Hook cheat sheet: JavaScript and TypeScript
How to add a vulnboxd runtime hook to a JavaScript and TypeScript 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.
Runtimes on this page: Node.js · Bun · Deno.
Node.js
| Setup | Use this when | Change | Hub automation |
|---|---|---|---|
| Node.js runtime hook (NODE_OPTIONS) | Depends on express, koa, fastify, @hapi/hapi, @nestjs/core or 4 more (in package.json) | compose | fully |
| Node.js runtime hook (NODE_OPTIONS --import, Node ≥ 20.6) | Whose sources match the rules below | compose | fully |
Without source access
Only the compose file changes: the image and the code stay as they are.
Node.js runtime hook (NODE_OPTIONS)
- Use this when: Node.js service that depends on
express,koa,fastify,@hapi/hapi,@nestjs/coreor 4 more (inpackage.json). - Hub automation: fully. The hub proposes exactly this change and pushes it (one commit per container) once you approve it. Do it by hand only when the proposal failed, e.g. on an unusual compose file.
- Check and undo: hook mounted into the container
Mounts the vulnboxd hook directory read-only and preloads /opt/vbxtrace/node/register.js with NODE_OPTIONS=--require, so requests in the Node event loop are linked to the processes, connections and files they cause. Image and source stay untouched; remove the two lines (or set VBXTRACE=0) to turn it off.
Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
environment:
NODE_OPTIONS: "--require /opt/vbxtrace/node/register.js" # already set? append, separated by a spaceExact detection rules
Package N1 (Node.js core binding), proposal N1:compose, defined in hooks/node/n1/proposals/compose.toml.
- Image matches (regex):
^(docker\.io/)?(library/)?node:,^(docker\.io/)?keymetrics/pm2,^(docker\.io/)?(library/)?ghost:,^(docker\.io/)?nodered/ - Command matches (regex):
\bnode\b,\bnpm\s+(run\s+)?start\b,\bnpx\b,\byarn\s+start\b,\bpnpm\s+start\b,\bpm2-runtime\b,\bnodemon\b,\bts-node\b,\btsx\b - Dependency on:
express,koa,fastify,@hapi/hapi,@nestjs/core,next,restify,ws,socket.io - Files:
package.json,package-lock.json,npm-shrinkwrap.json,yarn.lock,pnpm-lock.yaml,*.js,*.mjs,*.cjs
Node.js runtime hook (NODE_OPTIONS --import, Node ≥ 20.6)
- Use this when: Node.js service whose sources match the rules below.
- Hub automation: fully. The hub proposes exactly this change and pushes it (one commit per container) once you approve it. Do it by hand only when the proposal failed, e.g. on an unusual compose file.
- Check and undo: hook mounted into the container
Mounts the vulnboxd hook directory read-only and preloads /opt/vbxtrace/node/register.mjs with NODE_OPTIONS=--import. Same hooks as the --require variant; needs Node 20.6 or newer.
Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
environment:
NODE_OPTIONS: "--import /opt/vbxtrace/node/register.mjs" # already set? append, separated by a spaceExact detection rules
Package N1 (Node.js core binding), proposal N1:compose-esm, defined in hooks/node/n1/proposals/compose-esm.toml.
- Image matches (regex):
^(docker\.io/)?(library/)?node:(2[0-9]|[3-9][0-9])
Bun
| Setup | Use this when | Change | Hub automation |
|---|---|---|---|
| Bun runtime hook (BUN_OPTIONS, Bun ≥ 1.3.7) | Whose sources match the rules below, and only if Bun is 1.3.7 or newer (from the image tag) | compose | with conditions |
| Bun runtime hook (--preload in the command) | Depends on @types/bun, bun-types, hono or elysia (in package.json) | compose | with conditions |
| Bun runtime hook (bunfig.toml preload) | On the image oven/bun | compose + mounted config | fully |
Without source access
Only the compose file changes: the image and the code stay as they are.
Bun runtime hook (BUN_OPTIONS, Bun ≥ 1.3.7)
- Use this when: Bun service whose sources match the rules below, and only if Bun is 1.3.7 or newer (from the image tag).
- Hub automation: with conditions. The hub proposes and pushes exactly this change. Only when the image tag shows bun 1.3.7 or newer; otherwise do it by hand.
- Check and undo: hook mounted into the container
Mounts the vulnboxd hook directory read-only and preloads /opt/vbxtrace/bun/register.ts through BUN_OPTIONS. Needs Bun 1.3.7 or newer (older versions stop the service).
Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
environment:
BUN_OPTIONS: "--preload /opt/vbxtrace/bun/register.ts" # already set? append, separated by a spaceExact detection rules
Package N4 (Bun), proposal N4:compose-bun-options, defined in hooks/node/n4/proposals/compose-bun-options.toml.
- Image matches (regex):
^(docker\.io/)?oven/bun:(1\.3\.([7-9]|[1-9][0-9])|1\.([4-9]|[1-9][0-9])(\.|-|$)|[2-9]) - Required: bun 1.3.7 or newer
Bun runtime hook (--preload in the command)
- Use this when: Bun service that depends on
@types/bun,bun-types,honoorelysia(inpackage.json). - Hub automation: with conditions. The hub proposes and pushes exactly this change. Only when the command is an exec-form list it can extend; otherwise do it by hand.
- Check and undo: hook mounted into the container
Mounts the vulnboxd hook directory read-only and adds --preload /opt/vbxtrace/bun/register.ts right after bun in the service's command.
Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
# command: insert --preload /opt/vbxtrace/bun/register.ts right after the element that runs bun
# e.g. command: ["<that element>", "--preload", "/opt/vbxtrace/bun/register.ts", "<the rest as it was>"]Exact detection rules
Package N4 (Bun), proposal N4:compose-preload-command, defined in hooks/node/n4/proposals/compose-preload-command.toml.
- Image matches (regex):
^(docker\.io/)?oven/bun(:|$) - Command matches (regex):
^\s*(\[\s*"?)?(\S*/)?bun"?(\s|,|$) - Dependency on:
@types/bun,bun-types,hono,elysia
Bun runtime hook (bunfig.toml preload)
- Use this when: Bun service on the image
oven/bun. - Hub automation: fully. The hub proposes exactly this change and pushes it (one commit per container) once you approve it. Do it by hand only when the proposal failed, e.g. on an unusual compose file.
- Check and undo: hook mounted into the container
Mounts the vulnboxd hook directory read-only and a bunfig.toml whose preload loads /opt/vbxtrace/bun/register.ts, so Bun.serve requests are linked to the processes, connections and files they cause. Image and source stay untouched.
Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
- /usr/local/lib/vulnboxd/trace/bun/bunfig.toml:<workdir>/bunfig.toml:roThe mounted file, as the hook directory has it (hooks/node/n4/bun/bunfig.toml):
# Mounted as the service's bunfig.toml (config-only way in) when the service has none of its own.
preload = ["/opt/vbxtrace/bun/register.ts"]Exact detection rules
Package N4 (Bun), proposal N4:config-bunfig, defined in hooks/node/n4/proposals/config-bunfig.toml.
- Image matches (regex):
^(docker\.io/)?oven/bun(:|$) - Command matches (regex):
(^|[\s/"'])bun(\s|$),\bbunx?\s - Files:
bun.lockb,bun.lock
Deno
| Setup | Use this when | Change | Hub automation |
|---|---|---|---|
| Deno runtime hook (--preload in the command, Deno ≥ 2.4) | Started with deno run, and only if Deno is 2.4.0 or newer (from the image tag) | compose | with conditions |
| Deno runtime hook (import in the entry module) | Started with deno run | source, rebuild | not at all |
Without source access
Only the compose file changes: the image and the code stay as they are.
Deno runtime hook (--preload in the command, Deno ≥ 2.4)
- Use this when: Deno service started with
deno run, and only if Deno is 2.4.0 or newer (from the image tag). - Hub automation: with conditions. The hub proposes and pushes exactly this change. Only when the image tag shows deno 2.4.0 or newer, the command is an exec-form list it can extend; otherwise do it by hand.
- Check and undo: hook mounted into the container
Mounts the vulnboxd hook directory read-only and adds --preload /opt/vbxtrace/deno/register.ts plus FFI and read permission for /opt/vbxtrace (and env permission for the VBXTRACE switch) after deno run, so Deno.serve requests are linked to the processes, connections and files they cause.
Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
# command: insert --preload /opt/vbxtrace/deno/register.ts --allow-ffi=/opt/vbxtrace --allow-read=/opt/vbxtrace --allow-env=VBXTRACE right after the element that runs run
# e.g. command: ["<that element>", "--preload", "/opt/vbxtrace/deno/register.ts", "--allow-ffi=/opt/vbxtrace", "--allow-read=/opt/vbxtrace", "--allow-env=VBXTRACE", "<the rest as it was>"]
# (leave out --allow-ffi=/opt/vbxtrace --allow-read=/opt/vbxtrace --allow-env=VBXTRACE when the command has -A or --allow-all)Exact detection rules
Package N5 (Deno), proposal N5:compose-preload-command, defined in hooks/node/n5/proposals/compose-preload-command.toml.
- Image matches (regex):
^(docker\.io/)?denoland/deno(:|$) - Command matches (regex):
\bdeno\s+run\b - Files:
deno.json,deno.jsonc,deno.lock - Required: deno 2.4.0 or newer
With source access
These change the service's code or Dockerfile, then it is rebuilt.
Deno runtime hook (import in the entry module)
- Use this when: Deno service started with
deno run. - Hub automation: not at all. The hub lists these steps with its proposal but changes nothing.
- Check and undo: hook built into the service
Adds import "/opt/vbxtrace/deno/register.ts"; as the first line of the service's entry module, mounts the hook directory read-only and grants FFI and read permission for /opt/vbxtrace (unless the command already uses -A).
Source change, then rebuild:
- add
import "/opt/vbxtrace/deno/register.ts";as the first line of the entry module (the file afterdeno run) - mount
/usr/local/lib/vulnboxd/traceat/opt/vbxtrace(read-only) in the compose file - add
--allow-ffi=/opt/vbxtrace --allow-read=/opt/vbxtrace --allow-env=VBXTRACEto thedeno runcommand unless it has-A/--allow-all
Example change on a sample service (hooks/node/n5/proposals/deno-import.diff):
--- a/main.ts
+++ b/main.ts
@@ -1,3 +1,4 @@
+import "/opt/vbxtrace/deno/register.ts";
import { Hono } from "jsr:@hono/hono";
const app = new Hono();
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,4 +3,6 @@ services:
<service>:
build: .
- command: ["deno", "run", "--allow-net", "main.ts"]
+ command: ["deno", "run", "--allow-ffi=/opt/vbxtrace", "--allow-read=/opt/vbxtrace", "--allow-env=VBXTRACE", "--allow-net", "main.ts"]
+ volumes:
+ - /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:roExact detection rules
Package N5 (Deno), proposal N5:source-import, defined in hooks/node/n5/proposals/source-import.toml.
- Image matches (regex):
^(docker\.io/)?denoland/deno(:|$) - Command matches (regex):
\bdeno\s+run\b - Files:
deno.json,deno.jsonc,deno.lock
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.
Hook built into the service
Check: After the rebuild, the binary carries the hook's probes (a count above 0):
readelf -n <the built binary> | grep -c vbxtraceThe 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 change.