Node HTTP frameworks (N2)
Ready
This package comes with the N1 hook: when the hub proposes N1 for a container, this is part of it, and nothing changes until a player approves the proposal (Hook proposals). The cheat sheet has the steps by hand.
For Node web frameworks: Express, Koa, Fastify, Hapi, NestJS, Next.js, Nuxt/Nitro, Restify, Sails, Remix, AdonisJS and the core http2 server. Everything that serves through Node's http/https servers is already covered by N1's request hook — the frameworks need nothing of their own, and N2's samples verify that for each of them, including streamed responses and request bodies parsed by the framework. N2 adds the http2 server (plain and TLS, core and compatibility API), where every stream is a request. It is part of the Node hook that N1's register.js loads from /opt/vbxtrace/node/n2, so it gets in with the same compose-only change.
Covers
| Versions (sampled) | |
|---|---|
| Node.js | as N1: 16–24 (framework samples run on Node 22, Alpine) |
| Express | 4.21.2, 5.1.0 |
| Koa | 2.16.1 (@koa/router 13.1.0, @koa/bodyparser 5.1.1) |
| Fastify | 5.4.0 |
| Hapi | 21.4.0 |
| NestJS | 11.1.3 (Express adapter) |
| Next.js | 15.3.4 (standalone server) |
| Nuxt / Nitro | Nuxt 4.6.2 (Nitro node-server preset, nitropack 2.13.5) |
| Restify | 11.1.0 |
| Sails | 1.5.18 |
http2 | core server: h2c (compatibility API) and TLS (core stream API) |
| Remix | React Router 8.4.0 framework mode (Remix's successor), served by react-router-serve |
| AdonisJS | 6.21.0 (node ace build, slim starter layout) |
| Meteor | not sampled: needs the Meteor tool and its own build system (about 1 GB); it serves through node:http, so N1's hook applies |
What the kernel already links without a hook: nothing — every Node framework serves its requests on the one event-loop thread.
How it gets in
From a registry (local development, or a build with network; the same release as the hook directory): npm install vbxtrace@1.0.0, then node --require vbxtrace/register app.js (ESM: --import vbxtrace/register.mjs); see Local development.
Exactly as N1: the hub proposes N1's template (hooks/node/n1/proposals/compose.toml), whose detection already lists the frameworks (express, koa, fastify, @hapi/hapi, @nestjs/core, next, restify, …). N2 has no template of its own because nothing about it is configurable.
services:
<service>:
+ volumes:
+ - /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
+ environment:
+ NODE_OPTIONS: --require /opt/vbxtrace/node/register.jsFrameworks with a build step (Next.js, Nuxt, Remix, AdonisJS) need nothing at build time: the hook only acts in the running server process, so the image is built exactly as before.
What it records
| Event | Emitted from | Join key |
|---|---|---|
request_begin / request_end (HTTP/1.1) | N1: http.server.request.start / http.server.response.finish — for every framework on node:http/https; request_end comes when the response is finished, so a streamed (chunked) response ends after its last chunk | peer address and port, request index on the keep-alive connection |
request_begin (protocol http2, or grpc when the content-type is application/grpc*) | the http2 server's 'stream' event (a guarded wrap of the server prototypes' emit; the compatibility API's 'request' is emitted from inside it) | the session socket's local port, peer address and port, request index = the stream's 0-based order on the session |
request_end (http2) | the stream's 'close', with the :status it sent (0 if none) | context id |
spawned, opened, connected, context_enter/context_exit | N1's hooks, inside the request's context | as N1 |
Context following
N1's AsyncLocalStorage context covers each framework's whole request pipeline: middleware, async handlers, body parsers (which read the body in later socket events — the request and response objects are bound to the request's context), streamed responses and timers. For http2, the 'stream' listeners run inside the stream's context and the stream (plus the compatibility API's request/response objects) is bound to it.
Known gaps
- Framework-internal work is attributed to the request it happens in. Lazy
require()s of framework modules during the first requests show up ascontext_enter/context_exitpairs (readFileSyncthrough Node's module loader); Next.js reads its 404 page throughfs.promises(anopenedwith unknown flags). These are real, correct events; the samples ignore them in their golden files.
Safety
- Wrapped by N2: the
http2server prototypes'emit(only'stream'and'request'are acted on; the prototypes are taken from unlistenedhttp2.createServer()/createSecureServer({})instances, which do no I/O),Http2ServerRequest.prototype.emit,Http2ServerResponse.prototype.emitand the server stream prototype'semit(binding owned objects' events to their context). One'close'listener is added to each stream. Everything else is N1's. - Same failure behaviour as N1: every core call guarded, off after 5 internal errors,
VBXTRACE=0switches the whole Node hook off, nothing but oneenabled()call while no tracer is attached. - Overhead: not measured yet; it will be measured in the performance phase.
Verified (hooks/run-samples.sh node --package n2, Node 22 on Alpine). Each framework sample serves: two requests on one keep-alive connection (indexes 0 and 1, the second a 404), child_process.execFile in a handler, fs.writeFile in an async handler, an outgoing http.get, a streamed response with a file opened between chunks, and a JSON body parsed by the framework followed by a file write.
| Sample | events | chaos | baseline |
|---|---|---|---|
express (4) | 37 events match | byte-identical | byte-identical |
express5 | 39 events match | byte-identical | byte-identical |
koa | 37 events match | byte-identical | byte-identical |
fastify | 19 events match | byte-identical | byte-identical |
hapi | 19 events match | byte-identical | byte-identical |
nestjs | 39 events match | byte-identical | byte-identical |
nextjs | 24 events match | byte-identical | byte-identical |
nuxt | 35 events match | byte-identical | byte-identical |
restify | 19 events match | byte-identical | byte-identical |
sails | 37 events match | byte-identical | byte-identical |
remix | 23 events match | byte-identical | byte-identical |
adonis | 39 events match | byte-identical | byte-identical |
http2 | 30 events match: six streams on one h2c session (indexes 0–5, the last grpc) and six on one TLS session | byte-identical | byte-identical |
(Event counts differ by the framework-internal context_enter/context_exit pairs the golden files ignore; the events checked are the same for every framework.)
Turning it off
Set VBXTRACE=0 in the service's environment and restart it, or revert the change that added the hook; vulnboxd's rollback covers a hook that breaks a service. N2 has no switch of its own: it is part of the Node hook.
Troubleshooting
- Are the probes there?
readelf -n /usr/local/lib/vulnboxd/trace/libvbxtrace-x86_64.solists them;sudo bpftrace -l 'usdt:/usr/local/lib/vulnboxd/trace/libvbxtrace-x86_64.so:*'too. - Is the hook loaded? As N1:
grep vbxtrace /proc/<pid>/maps. - Which links did a flow get? The hub shows each link's method; this package's are
hook:N2(http2) andhook:N1(everything onnode:http). - Next.js / Nuxt / Remix started through a process manager or
npm start:NODE_OPTIONSreaches the server process through the parent, which loads the hook too (harmlessly). Check the server process's maps, not the parent's.