Problem
Nothing running inside a sandbox can prove to an external service that it is a
particular sandbox of a particular deployment. Management requests use a
user-session or service bearer token, command connections use session-scoped
attachment tokens, and spaced reaches the host over the guest's vsock
connection, but none of these is something guest code can present outward
(docs/architecture.md: "Management and attachment tokens are not
interchangeable").
An integrator who wants sandbox code to authenticate to an external system
therefore has one option today: inject a bootstrap secret into the sandbox
environment at create time. That is the pattern the credential design avoids
everywhere else. The secret sits in the guest where a prompt-injected or
compromised workload can read it, and the first handshake is sponsored by
whoever handled the secret rather than by the platform, which already knows the
sandbox's template digest, tenant and selected egress_profiles
(docs/egress-profiles.md).
This matters for the stated use of running agent code. The systems that admit an agent to resources, credential brokers, authorization services, a customer's own APIs, need to decide "is this a sandbox of tenant T, built from digest D, bound to profile P" without trusting what the guest says about itself.
Prior art
Every peer platform solves this with a platform-signed, audience-bound,
short-lived token the workload requests from inside: Fly Machines (OIDC token
from the Machines API), Kubernetes (projected service-account tokens via
TokenRequest), GitHub Actions (job OIDC token), and SPIFFE SVIDs as the
general form. SPACE already has the two prerequisites: a sanctioned guest-to-
platform channel, and a sandbox record carrying verifiable facts.
Proposed approach
1. Request path. The guest asks spaced for a token with a chosen
audience; spaced relays the request over its existing host channel; the
platform signs and returns it. spaced never holds a signing key. Two
candidate guest surfaces, for maintainers to choose:
| Option | Shape | Trade-off |
|---|---|---|
Local endpoint served by spaced | GET /v1/identity/token?audience=<aud> on the guest's local listener | Composes with audience selection; mirrors Fly and GitHub |
File refreshed by spaced | A token file with a fixed audience from the sandbox spec | Simplest for shells and legacy tools; one audience per sandbox |
2. Signing. Control-plane signing with a per-deployment key, so one issuer and one key set per deployment. This is the same deployment key and well-known JWKS proposed in #546 for signed execution records; one key infrastructure would serve both.
3. Token. A compact JWS (ES256) with standard claims and platform facts
under a space claim:
| Claim | Value |
|---|---|
iss | management API base URL |
sub | sandbox id |
aud | caller-chosen, required |
iat, exp, jti | expiry at most ten minutes after issue |
space.deployment | deployment identifier |
space.tenant | tenant, when the record has one |
space.template_digest | the resolved template digest already on the sandbox |
space.egress_profiles | the selected profile names already stored on the sandbox |
space.created_at | sandbox creation time |
Names only for profiles, not resolved allow lists, so operator configuration is not disclosed and the token stays small.
4. Discovery. /.well-known/openid-configuration and
/.well-known/jwks.json on the management API, so any standard OIDC verifier
works without a custom client.
5. Companion, independently useful. Expose template_digest and
egress_profiles on the sandbox object from GET /v1/sandboxes/{id} if they
are not already, so a verifier holding a management token can confirm a sandbox
by read where token issuance is not enabled.
6. Scope. Native sandboxes first; the E2B compatibility wrapper is unaffected. Behind a deployment-level configuration flag, off by default.
Why now
docs/versioning.md names 0.9.0 as the final planned breaking-change release
and puts the native HTTP API and the spaced-bridge gRPC API inside the 1.0
compatibility contract. The guest-side surface for this token lands in exactly
those contracts, so settling its shape before 1.0 is cheaper than adding it
after. Additive either way.
Security considerations
- The token proves "a process inside sandbox X, from digest D, in deployment Y, with profiles P". It says nothing about code behaviour beyond the digest; verifiers should constrain on digest, tenant and profiles, not on id alone.
- The request path is the per-sandbox channel, so one sandbox cannot obtain another's token.
- Short expiry plus
jtibound replay; requiredaudbounds reuse across verifiers. - Branching yields a new sandbox id and new tokens; tokens for a prior id expire within minutes. Pause and resume need no special handling at that expiry.
- Issuance should be rate limited per sandbox and logged like other control-plane events.
- No change to egress enforcement, TLS interception, credential injection, or the precedence of denies.
Questions for maintainers
- Endpoint served by
spaced, or a refreshed file, or both? - Control-plane signing only, or node-local signing with an aggregated JWKS?
- Should this share the deployment key proposed in #546?
space.*nested claims, or flat prefixed claims?
Per CONTRIBUTING.md, I am asking for scope agreement before opening a pull request. No code has been written against the repository.
Self-assessed severity
Low, as an enhancement. Nothing is broken; the gap is that external systems cannot verify a sandbox's identity without a secret placed in the guest, which limits SPACE for workloads that must authenticate to anything outside it.
Offer
If the maintainers agree a shape, I will implement it behind the configuration
flag with a docs page listed in docs/book/SUMMARY.md, tests, and a verifier
example against the published JWKS. My company would sign the CCLA. We would
be the first external verifier of these tokens and would maintain a reference
integration and quickstart.
Disclosure: I work on Alter (alterauth.com), an authorization layer for agents. This issue was
drafted with AI assistance (Claude) and reviewed by me against the repository
docs on main as of 2026-10-21; it is submitted from my own account.
Thanks for opening this issue! A SPACE maintainer will take a look.
CONTRIBUTING.md explains how we review outside contributions.