Repository navigation
feat(sandbox): install Incus sessions through the node's registry caches - #5017
Merged
Merged
Conversation
yannickmonney
force-pushed
the
feat/sandbox-registry-caches
branch
from
October 19, 2026 13:40
15f2ffa to
1ee00f5
Compare
4 of 5 tasks
SANDBOX_INCUS_NPM_REGISTRY and SANDBOX_INCUS_PYPI_INDEX name the npm and PyPI caches an Incus session may install through. Both are optional and off by default. Boot refuses a value that is not an http URL whose host is an IPv4 literal (a session resolves no name before it reaches a cache) or that carries a character an .npmrc, ini file, TOML string or shell word would read differently. The PyPI trusted host is the index URL's own host and port, so the two cannot disagree. Boot logs which caches are set and which registry hosts the egress proxy should then refuse. The CLI's cross-check of the spawner's configuration modules and its test inputs name the new module.
With SANDBOX_INCUS_NPM_REGISTRY or SANDBOX_INCUS_PYPI_INDEX set, every instance and every warm standby carries the cache addresses in its environment (TALE_REGISTRY_CACHE_NPM and TALE_REGISTRY_CACHE_PYPI) and the cache hosts join NO_PROXY, because the egress proxy refuses private destinations. A standby made under other settings no longer matches the pool fingerprint and is replaced. With neither variable set the environment is byte for byte what it was.
The runtime entrypoint reads TALE_REGISTRY_CACHE_NPM and TALE_REGISTRY_CACHE_PYPI and, before runnerd starts, writes ~/.npmrc, ~/.bunfig.toml, ~/.config/pip/pip.conf and ~/.config/uv/uv.toml as the session user. pip trusts the index host and uv allows it, because a cache answers plain HTTP. Every start settles the files again: one the sandbox wrote (its first line is a marker) is rewritten, or removed once its cache is no longer named, so a resumed workspace never keeps the address of a cache that was switched off. A file without the marker is the owner's own and is never touched. A symbolic link is never followed: one that points at a file the sandbox wrote is replaced by a file, and any other is left alone. A value that is not a plain http URL, or a file that cannot be written, is a warning and never stops the boot. With neither variable set nothing is written or said.
SANDBOX_EGRESS_DENIED_HOSTS keeps egress open and refuses the host names it lists, each with its subdomains: tinyproxy answers a request or a CONNECT for one with 403, and the DNS forwarder answers it NXDOMAIN, so a client that resolves through the proxy and then connects by address fails at the name. A deployment whose sessions install through package caches lists the public registries, so that a package manager that ignores its configuration fails visibly instead of installing around the cache. Entries are plain host names with a domain, never regular expressions. The entrypoint stops the start on anything else, on a list that names no host, and when SANDBOX_EGRESS_ALLOWLIST is also set. Unset, the proxy renders exactly the config it did before.
A case of the Incus lab's network suite gives the spawner two stand-in caches on the gateway's address, one npm and one PyPI, each serving a package that exists nowhere else, adds an ACL rule for each port and gives the egress proxy the four registry hosts to refuse. A session then has the package manager files and the NO_PROXY entry, installs a locked npm project, a pip project locked by hash and the same requirements through uv from the stand-ins, and reaches no registry host: the proxy answers a tunnel to each 403 and its resolver NXDOMAIN, an npm told to use the public registry fails, and the rest of the web stays open. The case puts the ACL rules and the proxy back as it found them. The stand-ins make their packages themselves, and an offline test holds the archives, the lock files and the servers' answers in shape.
The Incus contract gets a section on the two cache settings and the egress proxy's list: what boot accepts, the ACL rule each cache needs, the files a session is given and when they are rewritten, replaced or left alone, how locked npm, bun, pip and uv installs go through the caches, and that the caches are shared by every organization, read-only and public only. The environment reference (English, German, French) lists SANDBOX_INCUS_NPM_REGISTRY, SANDBOX_INCUS_PYPI_INDEX and SANDBOX_EGRESS_DENIED_HOSTS, the hardening guide says where the deny-list fits beside the allow-list, and the verify-a-node list names what to check.
One list names the public registries the caches replace. A test holds the value the contract and each language of the environment reference give the egress proxy to it, the settings and variables those pages name to the code that reads them, and the variables the entrypoint reads to the ones the spawner sets. The proxy's own tests take their hosts from the same list. The spawner's test inputs name the files the new test reads outside its workspace.
tinyproxy matches the host of a request or a CONNECT as the client wrote it, and the proxy resolves that name itself. A deny-list entry for registry.npmjs.org therefore let registry.npmjs.org. through, a name that resolves to the same address and that the DNS forwarder's refusal never sees on this path. Each pattern now takes one trailing dot. Against tinyproxy 1.11.3 a CONNECT to the dotted name was tunnelled with the old pattern and answered 403 with the new one. The unit test matches the dotted forms, and the lab case tunnels to each registry host in both forms.
The template, the entrypoint and the firewall script described two egress modes, open and allow-list. SANDBOX_EGRESS_DENIED_HOSTS makes a third, open egress that refuses named hosts, so each comment now says which mode renders which filter and that the SSRF firewall applies in every one of them.
SANDBOX_EGRESS_DENIED_HOSTS reaches the container through the compose env_file, which docker compose restart does not read again, so a restart left the old list in force. The README now says to recreate the service, as the environment reference does.
SANDBOX_INCUS_NPM_REGISTRY and SANDBOX_INCUS_PYPI_INDEX join the Incus block and SANDBOX_EGRESS_DENIED_HOSTS joins the sandbox-egress settings, each commented out as its neighbours are. The entries say what each value is, that the ACL and the proxy's list go with them, that the egress proxy reads its list and must be recreated, and that the list and SANDBOX_EGRESS_ALLOWLIST exclude each other.
An image from before the cache settings writes no package manager files, so its sessions install from the public registries, which is harmless until the egress proxy refuses those hosts: then every install fails. The Incus contract said such a session installs as before, and the environment reference only asked for an image of the spawner's release. Both now say that the image and the spawner roll together and that the proxy's list is set last, in English, German and French.
The Incus contract said the egress proxy refuses to start on an empty
list. The entrypoint treats an empty SANDBOX_EGRESS_DENIED_HOSTS, what a
templated ${VAR:-} yields, as unset and starts with every registry open.
Only a value that names no host, such as a comma or a space, stops the
start.
Verdaccio answers GET /-/all with every package it has fetched, with its web interface off as on the node, so a session can list the public npm packages that sessions of other organizations installed, though not which organization installed them. devpi's index lists the whole upstream and not what was fetched. The contract said only that the operator of the caches sees it. Docker inside a session reaches the internet through the same egress proxy and resolves through the same forwarder, so with the proxy's list set a nested npm or pip install cannot reach the four registry hosts either, and the nested builder has no cache to fall back to. The contract implied those builds still reached the public registries.
write_registry_cache_files takes the home as its first argument, and its caller passes the literal /agent/.runtime/home. The tests do not pass a home. They run the whole entrypoint with /agent moved under a temporary directory, which the comment now says.
The stand-ins wrote a ustar tarball and a zip wheel byte by byte, about ninety lines of format code. The tarball is now made by Bun.Archive and the wheel by jszip, which @tale/platform and @tale/cli already depend on. jszip joins @tale/sandbox as a development dependency at the same exact version, in the workspace lockfile and in the lockfile the spawner image installs from. Bun stamps the time into a tarball, so probePackages is asynchronous and runs once per lab run, and the servers take its result as an option instead of making their own: the lock files and the servers share the bytes whose integrity the lock records. The offline test now reads the archives back with the libraries, which check each checksum. Real npm ci, pip install --require-hashes and uv pip install installed the probe packages from the stand-in servers.
The registry cache URL carried its own copy of the dotted-quad octet grammar that network-address.ts already owns and that SANDBOX_EGRESS_PROXY and SANDBOX_INCUS_DNS are read with. The URL pattern now only splits out a host made of digits and dots, and isIpv4Address decides whether it is an address, so one change to that grammar reaches the cache settings too. A test holds the two to each other.
The list refuses a registry host for every request, so with it set a session cannot open a page on pypi.org or registry.npmjs.org, and it cannot install a private package held on registry.npmjs.org even with a token of its own. The contract called browsing and private registries unaffected; it now says that only a private registry on another host keeps working.
The lab case installs through stand-in caches and checks the proxy's refusals, but it never plants a file of a session's own, stops the session and resumes it. That survival is held by the runtime entrypoint's tests, which run it over a home that already holds the file, and the verification list now says so next to the other things the lab leaves out.
The troubleshooting page for refused sandbox network access named only SANDBOX_EGRESS_ALLOWLIST. With SANDBOX_EGRESS_DENIED_HOSTS set, a 403 or an unresolved name for a package registry host is the intended answer, so the page now says that and sends the session to the registry caches, in English, German and French.
The contract test compared the registry host list with the Incus contract and the three environment references, while the env template and the egress proxy's README carry the same four hosts as an example an operator copies. A change to the list now fails there too, and the sandbox test task hashes both files.
yannickmonney
force-pushed
the
feat/sandbox-registry-caches
branch
from
October 19, 2026 18:00
1ee00f5 to
c4b2799
Compare
yannickmonney
added this pull request to the merge queue
Oct 19, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 19, 2026
yannickmonney
added this pull request to the merge queue
Oct 19, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 19, 2026
yannickmonney
added this pull request to the merge queue
Oct 19, 2026
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An Incus sandbox node can run package registry caches (an npm cache and a PyPI index on a network of their own). Today every session installs from the public registries through the egress proxy, so a node with many sessions downloads the same packages again and again and the caches serve none of them. This adds two optional spawner settings that point sessions at the caches, and an optional deny-list on the egress proxy so that a package manager that ignores its configuration fails visibly instead of installing around the cache. Everything is off unless set: a deployment that sets none of the three variables gets the same instance, environment, home and proxy configuration as before.
The Incus backend only. The Docker and Kubernetes backends and the nested Docker daemon are untouched.
What changes
SANDBOX_INCUS_NPM_REGISTRYhttp://URL whose host is an IPv4 addressSANDBOX_INCUS_PYPI_INDEXSANDBOX_EGRESS_DENIED_HOSTShttp:with an IPv4 literal host (the same grammarSANDBOX_EGRESS_PROXYis held to, throughisIpv4Address): a session's bridge resolver forwards nothing, so a session is given address literals, never names. Boot refuses a name,https:, credentials, a query, a fragment, and any character that an.npmrc, an ini file, a TOML string and a shell word would not all read the same.incus-registry-caches.tsis pure and holds the settings, the host list and the rendering of the instance variables.TALE_REGISTRY_CACHE_NPM/TALE_REGISTRY_CACHE_PYPIin the instance's environment (an address is no secret) and adds the cache addresses toNO_PROXY, because the egress proxy refuses private destinations. The runtime entrypoint then writes, before runnerd starts and at every start (resume included),~/.npmrc,~/.bunfig.toml,~/.config/pip/pip.confand~/.config/uv/uv.toml. The first line of each file says the sandbox wrote it: such a file is rewritten when the cache moves and removed when its setting is gone; a file without that line is the session's own and is never replaced or removed; a symbolic link in its place is not followed. A failed write is a warning, not the end of the boot. The warm pool's fingerprint moves with the settings, so a standby made before is replaced.SANDBOX_EGRESS_DENIED_HOSTSmakes tinyproxy answer403for a listed host and its subdomains, and the proxy's DNS forwarder answerNXDOMAINfor them. The documented value isregistry.npmjs.org,registry.yarnpkg.com,pypi.org,files.pythonhosted.org;REGISTRY_HOSTSin the spawner is the one list, boot prints the value for the caches that are set, and a test holds the docs,.env.exampleand the egress template's comment to it. The proxy refuses to start on an entry that is not a plain host name, on a list that names no host, and besideSANDBOX_EGRESS_ALLOWLIST. Browsing stays open: only the listed hosts leave the path.npm ciandbun install(a lock that records no registry) go through the cache. A pip requirements file locked by hash installs from the index. Auv.lockrecords the address of every file it was made against, souv syncgoes around the index and meets the proxy's refusal; the docs show the supported path (uv export --frozenthenuv pip install --require-hashes). No lock file is rewritten..npmrcorpip.confstays. The docs say plainly that the caches show which public packages were fetched (Verdaccio lists them) and what the deny-list takes away (a page onpypi.org, a private package held onregistry.npmjs.org).services/sandbox/docs/incus.md(settings table, a "Package registry caches" section, the capability row and the "Not supported" line, a verify step),.env.example,services/sandbox-egress/README.md,services/sandbox/README.md, anddocs/{en,de,fr}/self-hosted/(configuration/environment-reference.md,operate/security/hardening.md,operate/observability/troubleshooting.md). No UI string, so no message catalog changes.networksuite (services/sandbox/e2e/incus/suites/network.e2e.ts) with stand-in npm and PyPI servers (registry-stand-ins.ts, with its own offline tests): a session with the settings installs a locked npm project, a pip project locked by hash and the same requirements through uv from them, and reaches no registry host (a tunnel to each answers403, the nameNXDOMAIN) while another host stays open.jszip(devDependency of@tale/sandbox, pinned) builds the stand-ins' archives.services/sandbox/turbo.jsonandtools/cli/turbo.jsonlist the new files the suites read (the runtime entrypoint, the egress README,.env.example, the three environment references,incus-registry-caches.ts), and the CLI's spawner-configuration test helper lists the new module.Dormancy
With none of the three variables set: the instance's environment has no
TALE_REGISTRY_CACHE_*and an unchangedNO_PROXY; the pool fingerprint is the old one; the runtime entrypoint writes and removes nothing (it removes only a file that carries its own marker line); the egress proxy renders the configuration it rendered before. Tests hold each of these (incus-session-spec.test.ts,incus-config.test.ts,registry-cache-files.test.ts,egress-proxy-config.test.ts). An older runtime image with a newer spawner writes no files; the docs say to roll the image and the spawner together and to set the proxy's list last.Checklist
bun run checkpasses (format,lint:conflicts,lint:links,turbo run lint typecheck test test:ui), 49 of 49 turbo tasks, on the branch tip, which is onorigin/maind643fd5924with no rebase needed. The first two whole runs each failed one 5-second exec timing test of@tale/sandbox-runtime-daemonwhile the Mac was at load 30 (ExecManager > a cancelled exec ends its background processes too, thenan exec's environment > a command printing its environment never sees the token; neither touches this diff); the package passes alone (618 pass, 21 skip, 0 fail) and the whole gate passes with--concurrency=2. See the test plan.origin/main8693945855(one commit past the base above, no conflict; stacked locally, the branch is not rebased):bun run check --concurrency=2, 49 of 49 turbo tasks, exit 0 (@tale/sandbox2233 pass,@tale/sandbox-runtime-daemon618 pass,@tale/cli3829 pass, 0 fail in each).bun run lint:sastpasses (Opengrep): 476 rules on 5890 files, 0 findings.docs/{en,de,fr}/.docs/{en,de,fr}/.README.md/README.de.md/README.fr.md: N/A, no root README change (services/sandbox/README.mdandservices/sandbox-egress/README.mdare updated).Test plan
Local, bun 1.4.2,
NODE_OPTIONS=--max-old-space-size=6144for the type check:bun run checkover 49 turbo tasks, green on the last run:@tale/sandbox2233 pass, 1 skip, 0 fail;@tale/sandbox-runtime-daemon618 pass, 21 skip, 0 fail;@tale/cli3731 pass, 35 skip, 0 fail;@tale/platformtest 1488 files passed (2 skipped);test:ui778 files passed;@tale/docs38 files passed. 44 of the 49 tasks replayed from the shared Turbo cache that an earlier run of the same inputs filled; the sandbox, daemon, platform and CLI test tasks executed on that last run.incus-registry-caches.test.ts,incus-config.test.ts,config-incus.test.ts), the session spec (incus-session-spec.test.ts: default byte-identical, set adds the variables andNO_PROXY, the fingerprint moves), the entrypoint's files byte for byte, marker rules, removal, a foreign file and a link left alone (registry-cache-files.test.ts, which drives the real entrypoint), the proxy's rendering and refusals (egress-proxy-config.test.ts), and a contract test that holds the documented host list,.env.example, the three environment references and the egress template to the setting (incus-registry-caches-contract.test.ts).bun run lint:sast0 findings;bunx knipexit 0;commitlintover every commit of the branch passes.403on CONNECT and plain HTTP and withNXDOMAINfor it and its subdomains while another host reaches the internet; realnpm ci,pip install --require-hashes,uv pip install --require-hashesandbun installinstall from the lab's stand-in caches using the files the real entrypoint wrote (dash and bash);uv syncfrom auv.lockgoes around the configured index, as documented.Not run, and not claimed:
Ops follow-up
Nothing here is used until an environment sets the variables. After a release carries it, the ops repository sets
SANDBOX_INCUS_NPM_REGISTRYandSANDBOX_INCUS_PYPI_INDEXin the sandbox environment each platform declares, reading the cache addresses from the node's own cache declaration rather than restating them; adds an ACL rule for each cache's port to the sandbox zone; rolls the runtime image and the spawner together; and setsSANDBOX_EGRESS_DENIED_HOSTSon the egress proxy last (recreate it to apply).