Design: secrets proxy for Daytona sandboxes
How a Daytona sandbox reaches the secrets proxy and nothing else, how that is enforced and verified, and what it costs.
This started as a design; the provider path, the relay, the listener’s TLS mode and its limits are now built (see the secrets proxy), and a live check against a real account waits for a go. It extends the secrets proxy, which today confines Docker sandboxes, to the hosted setup: the worker runs on a platform such as Railway and the sandboxes run in Daytona’s cloud. Nothing here is built. Some facts about Daytona could only be settled on a real account, and the results of that spike are below; they changed the recommendation in one place (the allow-list mechanism).
The problem
The proxy only protects a secret if the sandbox has no other way out. With Docker, the sandbox sits alone on an internal network and a relay container is its only neighbour. A Daytona sandbox is in another provider’s network. The worker cannot attach a network interface to it, and the proxy is not on the same host. The design has to answer four questions:
- How does a Daytona sandbox reach the proxy, and only the proxy?
- How is the proxy exposed, safely, to the public internet?
- How is “only the proxy” enforced and verified before a job runs?
- What happens when a credential leaks, and what does it cost?
What Daytona gives us
From Daytona’s network limits documentation (checked at the time of writing, to be re-checked in the spike):
| Feature | What it does | Fit |
|---|---|---|
networkAllowList | Outbound traffic limited to a comma-separated list of IPv4 CIDR blocks. At most 10 entries. No hostnames, no IPv6. Set at create time or on a running sandbox. | Good: a per-sandbox firewall, deny by default once set. |
domainAllowList | Outbound traffic limited to listed hostnames, *. wildcards allowed, up to 100 entries. | Useful if the proxy has no stable IP. How a name is enforced is not documented; the spike found it is a filter on the TLS server name and HTTP Host header (see the results). |
networkBlockAll | No outbound traffic. | What the provider uses today for egress none. |
outboundProxyUrl | Create time only. Routes HTTP(S) through an upstream proxy and sets HTTP_PROXY and HTTPS_PROXY in the sandbox. Clients that ignore the variables are not routed. | Rejected below. |
| VPN clients (Tailscale, OpenVPN and others) | The sandbox joins a private network. Per sandbox, Tier 3 and up. | Rejected below. |
At create time only one of networkAllowList, domainAllowList and networkBlockAll may be set. Per-sandbox settings need Tier 3 or 4: on Tier 1 and 2 the organisation’s policy applies and a sandbox cannot override it. The documentation is not consistent about whether Daytona’s own “essential services” are reachable under an allow list. We do not rely on either reading: the canary measures what is reachable.
Options considered
A. Allow list to a public TLS endpoint, with a relay in the sandbox (recommended). The sandbox is created with an allow list that contains only the proxy’s public address. The proxy listens on a public TLS endpoint. A tiny relay inside the sandbox turns the plain local proxy address that tools use into a TLS connection to that endpoint.
B. outboundProxyUrl. Daytona would point the sandbox at our proxy for us. Rejected: the URL would carry the per-attempt credential, so the credential would sit in Daytona’s API request and in the sandbox record, which breaks the rule that the credential never appears in a provider call or log. It is only set at create time, and tools that ignore the variables go direct, so an allow list is needed anyway.
C. VPN or tailnet. The proxy is reachable only on a private network that the sandbox joins. Rejected: joining needs a VPN credential inside the sandbox, which is itself a secret a job could use for more than the proxy. It also adds a long-lived control plane, a tier requirement and several seconds to every start.
D. mTLS with a per-attempt client certificate. Rejected as the only control: clients disagree on whether they support client certificates for a proxy (curl does; most others do not). It could be added later as defence in depth.
E. Sandbox-initiated reverse tunnel. Rejected: it needs the same public endpoint as A plus a second protocol.
Recommendation: option A
How the sandbox reaches the proxy
- The provider creates the sandbox with
networkAllowListset to the proxy endpoint, in one create call, so there is no window with open egress. If the endpoint has no stable address it usesdomainAllowListwith the one hostname, and the canary decides whether that is acceptable (see the spike). - Only the proxy endpoint is reachable. No
0.0.0.0/0, no Daytona infrastructure range, no DNS server unless the spike shows the relay needs one. The relay connects to the endpoint’s address directly with the endpoint’s hostname as the TLS server name, and verifies the certificate against the system roots, so a hostile resolver or a spoofed address cannot impersonate the proxy. - After create, the provider uploads a small relay script with
files.putand starts it as a detached exec. The relay listens on127.0.0.1inside the sandbox, forwards each connection over TLS to the endpoint, and holds no credential. Tools getHTTP(S)_PROXY=http://<attempt credential>@127.0.0.1:<port>through the same0600environment file the Docker path uses, never through an argv. The relay speaks plain TCP in both directions, so it works for tools that cannot talk to an HTTPS proxy. - The relay is a Node script, because the sandbox image already carries Node for act. If the image has no Node the provider refuses the sandbox; it does not fall back to something weaker.
How the proxy is exposed
- The proxy gets its own public listener on its own port and hostname, separate from the HTTP API and UI, with a certificate from a public CA for that hostname (the platform’s managed certificate, or the proxy’s own ACME client). It speaks
CONNECTover TLS (an HTTPS proxy); the existing per-attemptProxy-Authorizationrides inside TLS, so the credential is never on the wire in clear. - The listener does nothing before authentication except read a capped request head, with a short handshake and head deadline. Unauthenticated connections cost a handshake and are dropped. Failed authentications are rate limited per source address and globally, and logged without the presented value.
- The credential is the one the proxy already issues:
attempt id : 256-bit random token, only a hash stored, constant-time comparison, expiry and revocation checked on every request, tunnels closed on revoke. Its lifetime is the job’s timeout plus a small margin, not hours. - The proxy and the API can run as separate services of the same deployment so a flaw in the public listener does not expose the API’s process. Both need the vault and the database, so the split is of exposure, not of trust. That is a deployment choice, not a code change.
How “deny all except the proxy” is enforced and verified
Enforced by the allow list at Daytona’s firewall. Verified by the canary, from inside the sandbox, before the job runs, extending the Docker canary:
- Direct paths closed. The existing probes of a public address and the cloud metadata address must fail.
- Private ranges closed. Probes of RFC 1918 addresses and Daytona’s own internal ranges must fail (the equivalent of the Docker host-address probe).
- A non-proxy public address closed on the proxy’s own port, so an allow list that is wider than intended (for example a whole provider range) is caught.
- The proxy open. The relay reaches the endpoint, completes TLS with the right name, and gets the proxy’s answer to a request without credentials (a 407).
The provider returns the list of targets that must not be reachable, as the Docker provider does with mustNotReach, and the job runner refuses to run if the list is empty or any probe is reachable or cannot be completed.
What fails closed
| Condition | Result |
|---|---|
| The account is below Tier 3, or the create call rejects the allow list | The provider refuses deny-all-except-proxy; the attempt ends as infra_error. |
| The allow list is accepted but not enforced (a probe gets out) | The canary fails; the sandbox is destroyed, the job does not run. |
A probe cannot be run (no curl in the image) | Treated as a failure for a proxied job, not as unknown. |
| The proxy endpoint is down or the certificate does not verify | The proxy probe fails; the attempt ends as infra_error. |
| The relay does not start | Same. |
| The worker restarts mid-job | The credential lived in the worker’s memory; a re-attached proxied attempt is refused, as today. |
| A credential expires or is revoked while a tunnel is open | The tunnel is closed. |
Threat model
| Threat | Defence |
|---|---|
| A stolen attempt credential (a job prints it, or reads the environment file) | It is valid for one attempt, for the rules and passthrough hosts of that attempt only, and dies when the attempt ends or is revoked. A thief can do what the job could do through the proxy and no more. The credential is redacted from the job’s log. A leaked credential is not a leaked secret: values never reach the sandbox. |
| Replay after the attempt | Expired and revoked credentials get the same 407 as unknown ones. |
| Guessing a credential from outside | 256 bits of randomness, constant-time comparison, rate limiting by source address. |
| Another tenant’s sandbox reaching our proxy | It has no credential, and it cannot use another attempt’s: each credential names its attempt and the attempt’s rules. The endpoint is public, so this rests on the credential, not on the network. |
| Our sandbox reaching other hosts | The allow list, verified by the canary on every start. |
| A hostile job tunnelling data out through the proxy | Only to hosts with a rule or a listed passthrough host and port, exactly as with Docker. |
| Interception between the relay and the proxy | TLS with certificate and name verification in the relay. |
| Daytona itself | Out of scope: it hosts the sandbox and sees what the sandbox sees, including the environment file in transit. Its gateway’s SSH port (TCP 22) is reachable from the sandbox under every network setting, as part of that boundary. The proxy exists so that raw secret values are never in that set. |
| Denial of service on the public listener | Handshake and head deadlines, connection caps per source and in total, work only after authentication, and the platform’s own protections. A flood costs availability of proxied jobs, not secrecy. |
Costs
- Per job: one create with an allow list (no extra call), a few small file and exec calls for the relay, and four canary probes: roughly one to three seconds of sandbox time added to a start, billed as sandbox minutes like the rest of the job.
- Always on: the proxy listener, a small service. If it shares the worker’s process there is no extra service.
- Bandwidth: traffic of proxied jobs goes through the platform that runs the proxy, so its egress is billed there. Rule hosts (a registry, an API) are small. Passthrough tunnels for checkout and package installs can be large: pre-staging sources and listing only the hosts a job needs keeps this down.
- Latency: one extra hop per connection. Noticeable for many small requests, not for a build.
- Account requirement: Tier 3 or above on the Daytona account that runs these jobs. Jobs that need no secrets stay on egress
noneand cost nothing extra.
Spike results
Run from one machine against a real Tier 3 account with the script packages/provider-daytona/scripts/proxy-spike.ts: five short runs, nine sandboxes, none alive more than about 25 seconds, 124 sandbox-seconds (about 2.1 minutes) in total, all deleted (nothing left). The org’s vCPU usage was checked before each create. Every probe ran inside the sandbox with curl (so it measures a real answer, not only a TCP connect). Results are as observed on the day and should be re-run when Daytona changes its firewall.
Setting an allow list
networkAllowListis accepted at create time on this account, in the same create call, so there is no window of open egress. The sandbox started and its toolbox answered, so the control channel is not affected by the list.- It can also be changed on a running sandbox:
POST /sandbox/{id}/network-settingswith{"networkAllowList": "<cidr>"}took about 0.6 seconds and was in force at the next probe (a previously listed address was refused straight away, a newly listed one was passed). - The sandbox image had
curl,node,python3,bash,getent,digandnslookup, and nonc. It runs as an unprivileged user. It has no IPv6 address or route.
What an IPv4 allow list does (list: one public address)
| Probe | Result, exactly as seen |
|---|---|
| The listed address | Answered: HTTP 301 for https://1.1.1.1/. |
| A non-listed public address, by IP literal | curl: (7) Failed to connect to 8.8.8.8 port 443 after 0 ms: Could not connect to server. An immediate refusal, not a timeout. |
RFC 1918 (10/8, 172.16/12, 192.168/16), CGNAT (100.64/10) and the cloud metadata address | The same immediate refusal, port 80. |
| Raw TCP to a non-listed address | bash: connect: Connection refused. |
| IPv6 literals, listed or not | The same immediate refusal. The sandbox has no usable IPv6, so there is no way around the IPv4 list. |
| A non-listed name, when the system resolver is itself on the list | The name resolves (the resolver answers) and then curl: (7) Failed to connect to example.com port 443 after 3 ms: Could not connect to server. |
| A non-listed name, when the resolver is not on the list | curl: (28) Resolving timed out after 8001 milliseconds. DNS is dropped silently, which looks like a timeout and not a refusal. |
| A listed address that does not answer | A timeout (Connection timed out after 8002 milliseconds), not a refusal. The difference tells a firewall refusal from a quiet destination. |
Two consequences. First, a resolver on the list is a data channel: any name resolves through it, so the list for a proxied job must hold only the proxy endpoint and the relay must connect to its address, not its name. Second, networkBlockAll behaves differently from a list: connections to a public address are accepted at TCP level and then end at TLS (curl: (35) ... unexpected eof while reading), so a probe must check for a real HTTP answer, as the existing canary does, and never trust a successful connect.
What is still reachable under a list or under networkBlockAll
The sandbox’s default gateway (172.20.0.1 in the runs; the address is Daytona’s, so read it from the route table) answers on two ports whatever the setting:
- TCP 18080, Daytona’s forward proxy (it is also what
HTTP_PROXYpoints at). It refuses to forward for a sandbox under a list or undernetworkBlockAll:CONNECT tunnel failed, response 403for a name and for a bare address, and HTTP 403 for plain http. It is not a way out. - TCP 22, an SSH server (banner
SSH-2.0-OpenSSH_9.x). Authentication was not attempted. It is a Daytona service, part of the platform’s own trust boundary, and cannot be closed from the sandbox side.
The sandbox’s resolvers in /etc/resolv.conf were 1.1.1.1, 1.0.0.1 and a CGNAT address (100.65.x.x). Under a list that held none of them, resolution timed out, so none of them answers a sandbox that is restricted.
What a domain allow list does (list: example.com)
| Probe | Result |
|---|---|
| The listed name | HTTP 200, with the proxy variables set in the environment (to the gateway, port 18080). |
| Another name through the environment proxy | curl: (56) CONNECT tunnel failed, response 403. |
| Another name, skipping the proxy | curl: (6) Could not resolve host: only listed names resolve. |
| A non-listed address, skipping the proxy, TLS | The TCP connection is accepted and then ends: curl: (35) ... unexpected eof while reading. |
| A non-listed address, plain http | curl: (52) Empty reply from server. |
The listed name’s SNI or Host header sent to a different address (1.1.1.1, 8.8.8.8) | HTTP 200, and a raw HTTP request to 1.1.1.1:80 with Host: example.com got example.com’s own response. |
So a domain list is enforced by a transparent filter on the TLS server name and the HTTP Host header, which ignores the destination address and delivers to the named host itself. It does not let a job reach any address it likes by faking a name (the traffic goes to the real host for that name), it drops everything that is not named, and it needs no stable address for the destination. Non-HTTP protocols that carry neither a server name nor a Host header are dropped. What it does not give is a hard network-level refusal: it relies on Daytona’s filter parsing the first bytes correctly.
The five questions
- Tier and per-sandbox lists. Tier 3. A per-sandbox allow list, a domain list and
networkBlockAllall work, at create time and on a running sandbox. - A stable endpoint address, and how a domain list is enforced. The address of a public hostname on the hosting platform was not tested, because no endpoint was deployed for the spike. A domain list is enforced as described above (server name and Host header, destination ignored), so it can carry a proxy whose address changes. A CIDR list needs the address to be stable.
- What is reachable. Nothing outside the list, including every private range, CGNAT and metadata, with two exceptions that are Daytona’s own: the gateway’s TCP 18080 (refuses to forward) and TCP 22 (SSH). The
mustNotReachprobes should therefore use a public address on the proxy’s port, a private-range address and the metadata address; they cannot include the gateway. - Tools in the image.
curlandnodeare present: the probes and the relay can be shipped as designed.ncis not. - Changing the list on a running sandbox. Possible and fast, but not needed: create-time lists leave no window.
What the results change
- The strict mechanism is the address allow list, and it is required. With a stable proxy address, use
networkAllowList(a hard refusal, DNS silently dropped, no resolver needed). AdomainAllowListof the proxy hostname works (the relay’s TLS connection carries that server name, so the filter delivers it) but rests on Daytona’s filter parsing the first bytes correctly, so it is a separate, weaker policy (proxy-domain-filtered) that the provider offers only when the operator setsallowDomainListConfinement: true, and a job uses only when the endpoint has no stable address.deny-all-except-proxyis never the domain list. - The relay still connects by address under a CIDR list and by name under a domain list; under neither does it rely on a resolver that is not the proxy’s.
- The canary probes with real requests. A TCP connect is not a signal on Daytona (
networkBlockAlland a domain list accept it and then drop); a probe passes only on the absence of an HTTP answer, which is what the existing canary tests. - A residual that cannot be closed: Daytona’s gateway SSH port stays reachable under every setting. It sits in the same trust boundary as Daytona itself (see the threat model) and is listed there.
What would be built
- Daytona
egressPolicygainsdeny-all-except-proxy, andproxyReachabilitybecomes true only where the canary can verify it. SandboxNetworkSpec.proxycarries the public endpoint (host, port, TLS name); the Daytona provider maps it to the allow list, installs the relay and returns the local address and themustNotReachlist.- The proxy gains a TLS listener mode, the per-source rate limits and the connection caps above.
- The canary gains the private-range and wrong-address probes. Nothing else in the job runner changes: it already works from
SandboxHandle.proxyandmustNotReach. - Tests: a fake Daytona API that records the create body (allow list present, no window), the relay against a local TLS proxy, the canary’s refusal cases, and the live check script run by hand against a real account under the existing sandbox limits.