Skip to content

Restrict sandbox egress with an allow-list - #72

Merged
jacobprall merged 1 commit into
mainfrom
jacob/sandbox-egress
Oct 28, 2026
Merged

jacobprall merged 1 commit into
mainfrom
jacob/sandbox-egress

Conversation

@jacobprall

Copy link
Copy Markdown
Collaborator

Fixes #65. Allow-list egress is available in the Sandboxes API (@renderinc/sdk 1.5). The API schema still marks it pre-GA, but this repo already relies on Sandboxes early access.

What changes

  • createSandbox now requires an egress host list and creates the sandbox with networkPolicy: { type: "allow-list" }. No sandbox can fall back to Render's default allow-all.
  • It refuses, and terminates, any sandbox whose reported policy is not allow-list or names hosts that weren't requested. If Render rejects the create, the error names the hosts and says the workspace may not support allow-list egress.
  • Build sandbox: factoryConfig.sandbox.buildEgress = registry.npmjs.org, deb.debian.org, apt.postgresql.org.
  • Publish sandbox: github.com only. Tokens are fetched on the workflow host, so the sandbox doesn't need api.github.com.
  • Postgres install fix: the allow-list admits HTTPS only, and the sandbox image's apt sources are plain HTTP (Debian, PGDG, backports). Without a change, apt-get install postgresql would fail. START_POSTGRES now uses a temporary sources list with two HTTPS sources.
  • SDK upgrade to 1.5: the sandbox client moved from render.experimental.sandboxes to render.sandboxes, and TaskContext gained metadata.
  • Docs: trust boundaries in docs/2_ARCHITECTURE.md, including the DNS channel the issue mentions, plus the setting in docs/1_EXTENSION.md.

Tested against real sandboxes

Build sandbox, created through the new createSandbox:

  • ensureSandboxPostgres installed PostgreSQL 18.6 from the HTTPS mirrors.
  • npm install vite react react-dom esbuild pg typescript tsx succeeded, including esbuild's platform binary.
  • Loopback HTTP on 127.0.0.1 works, so verification's local health checks still work.
  • example.com and github.com are blocked.

Publish sandbox:

  • git ls-remote https://github.com/... works.
  • registry.npmjs.org and api.github.com are blocked.

npm run check passes: 108 tests, including a new widerEgress test and an assertion on which hosts each sandbox gets.

Risk

A generated stack that downloads during install from a host other than npm will now fail in verification. Examples are packages that fetch binaries from GitHub releases, or a non-Node toolchain. The fix is to add the host to buildEgress. Please run one full fullstack prompt end to end before merging.

Made with Cursor

createSandbox now requires the hosts a sandbox may reach and creates it
with an allow-list network policy. It refuses a sandbox whose reported
policy admits more. The build sandbox reaches the npm registry and the
two apt mirrors its Postgres installs from, set in
factoryConfig.sandbox.buildEgress. The publish sandbox reaches only
github.com. The allow-list admits HTTPS only and the image's apt sources
are HTTP, so the Postgres install reads two HTTPS sources of its own.

Moves to @renderinc/sdk 1.5, where the sandbox client is render.sandboxes.

Closes #65

Co-authored-by: Cursor <cursoragent@cursor.com>
@jacobprall
jacobprall merged commit c194e9b into main Oct 28, 2026
3 checks passed
@jacobprall
jacobprall deleted the jacob/sandbox-egress branch October 28, 2026 20:32
@jacobprall
jacobprall restored the jacob/sandbox-egress branch October 28, 2026 20:32
@jacobprall
jacobprall deleted the jacob/sandbox-egress branch October 28, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Restrict Sandbox egress with an allow-list when it ships

1 participant