/** * The harness that runs inside the sandbox child. * * Embedded as a string rather than kept as its own `.mjs` file because `tsc` * copies no non-TypeScript files into `dist`, and a runtime that cannot find * its own harness after `npm install` is a packaging bug waiting to happen. * It is passed to `node -e`, so it must be plain JavaScript — and it must not * contain a backtick, which would end the template literal it lives in. * * THE SCRIPT DOES NOT RUN IN THIS REALM. An earlier version ran it with * `new AsyncFunction(code)` in the harness's own global scope and tried to take * dangerous things away afterwards — shadowing `require`, deleting `fetch`, * replacing `globalThis.process` with a stub. A review found three ways round * that, all confirmed by running them: * * (await import("node:process")).default dynamic import ignores shadowing * globalThis.require("node:process") `node -e` puts require on globalThis * Function('return import("node:process")')() and so does generated code * * and the real `process` matters, because `process.kill` is not gated by the * permission model: `process.kill(process.ppid, 0)` returned true. A script * could SIGKILL this server, or any other process its user owns. * * Taking things away from a realm that has everything is a list that is never * finished. So the script now gets a realm that has nothing: * * - a fresh `vm` context whose only globals are `jsm` and `console`, so there * is no `process`, `require`, `fetch` or timer to remove; * - compiled with no dynamic-import callback, so `import()` throws; * - code generation from strings disabled in the context AND, by a flag on * the child, in this realm — which is what closes the classic way out of a * vm context, `someHostFunction.constructor("return process")()`; * - values handed to the script are parsed inside the context, so the only * host-realm objects it ever holds are the functions it calls. * * Node documents `vm` as not being a security mechanism on its own, and this * does not lean on it alone: `--permission` is still the boundary for the * filesystem, the network and subprocesses. The context is what keeps a script * away from the one dangerous thing the permission model leaves reachable. * * The script arrives over stdin, not in argv. Argv is visible to anything that * can list processes on the machine, and a script may legitimately contain * alert text, an account id or a query someone would not want there. */ export declare const RUNNER_SOURCE: string; /** * Asks a child, started exactly as a script's child is, whether the boundary * actually holds on this runtime. * * It exists because the boundary was once assumed from one machine. The * permission model gates the network only from Node 25: on Node 24 — which * this package's `engines` field permits — `--permission` leaves sockets wide * open, and nothing but a real attempt would have said so. Every probe here * must come back ERR_ACCESS_DENIED; anything else and the sandbox refuses to * run scripts at all. */ export declare const SELFTEST_SOURCE: string; //# sourceMappingURL=runner.d.ts.map