Skip to content

Per-sandbox SPIFFE identity for provider token grants #6049

In review

Description

@shiju-nv

User Story

As a platform engineer, I run one OpenShell gateway for a fleet of agent sandboxes on several machines, shared by several teams. The agents call internal APIs that accept access tokens from our OAuth token service.

I need each sandbox to get its tokens as itself, with no secret stored in a sandbox or on a machine. Then our APIs can authorize, limit, and log each agent separately, and stopping one sandbox ends its access and nobody else's. I want the same provider profile to work on Docker, Podman, and MicroVM.

What I can do today does not meet that:

  • One client secret copied to every machine. The API sees one caller for every agent, so it cannot give one team's agents different rights from another's, or name the agent behind a call. A leak on one machine means a rotation on all of them.
  • The identity each machine's SPIFFE agent returns, which is what Docker and Podman give today. Every supervisor on a machine carries the same evidence, so they all get the same subject, and a supervisor left over from an earlier start still matches.
  • A secret per sandbox. Each must be minted, delivered to the right machine, rotated, and deleted, and nothing ties it to the launch that is alive now.

The gateway is on a different machine from most supervisors and cannot inspect the process that calls it. It needs proof it can check remotely of which sandbox the caller serves and whether it is the current launch. The need is the same with many sandboxes on one machine.

Problem Statement

A provider token grant is the token_grant credential of a provider profile. OpenShell stores no secret for it: it presents a SPIFFE JWT-SVID to an OAuth token service and receives a short-lived access token, which the supervisor adds to the agent's request.

OpenShell has several paths for these grants. Docker and Podman can connect dedicated supervisors to a configured Unix Workload API socket, and the supervisor performs the OAuth exchange itself with whatever identity its attestor returns. Nothing on the supervisor says which sandbox launch it serves, so every supervisor looks the same to the issuer, and the gateway cannot deny a supervisor it has replaced. The MicroVM host supervisor has no Workload API socket at launch. On Kubernetes the gateway broker binds issuance to a stable Sandbox resource.

Operators lack a common way to configure and verify a stable per-sandbox identity across the dedicated drivers.

Impact / Why This Matters

Operators must establish a runtime-specific identity mapping or use other provider credentials where attested grants are unavailable. A shared service credential gives the token service the same identity for every sandbox, which prevents per-sandbox authorization and attribution there and at the APIs behind it. The closed request #2708 focused on Workload API access across drivers. Current driver layouts also need a way to establish which supervisor may obtain each sandbox identity.

Proposed Design

An opt-in gateway mode for dedicated supervisors on Docker, Podman, and MicroVM. It is off unless [openshell.gateway.spiffe_workload_identity] is set. Kubernetes keeps the existing SPIFFE Broker API mode.

Architecture

flowchart LR
  subgraph HOST["Sandbox host"]
    subgraph SBX["Sandbox, untrusted"]
      A["Agent<br/>holds no credential"]
    end
    S["Supervisor<br/>one per sandbox"]
    D["Compute driver<br/>Docker, Podman or MicroVM"]
    W["Workload API socket<br/>the issuer's agent on this host"]
  end

  G["Gateway<br/>verifies both identities,<br/>then gets the token"]
  T["Token service<br/>OAuth authorization server"]
  U["Upstream API<br/>the service the agent calls"]
  I["SPIFFE issuer<br/>run by the operator,<br/>for example SPIRE"]

  A -->|"1: plain HTTP request"| S
  S -->|"2: fetch two JWT-SVIDs"| W
  S <-->|"3: session JWT + two JWT-SVIDs<br/>6: access token only"| G
  G <-->|"4: stable JWT-SVID as client assertion<br/>5: access token"| T
  S -->|"7: request with the token added"| U

  G -.->|"A: launch bundle with both SPIFFE IDs"| D
  D -.->|"B: starts it, marked with the launch ID"| S
  I -.->|"C: attests the caller, signs JWT-SVIDs"| W
  I -.->|"D: trust bundle"| G

  classDef untrusted fill:#fdecea,stroke:#c0392b,color:#5b1a12
  classDef openshell fill:#e8f1fb,stroke:#2b6cb0,color:#12324f
  classDef operator fill:#eef7ea,stroke:#3c8d40,color:#1c4a1e
  classDef external fill:#f4f0fa,stroke:#6b4fa0,color:#33255a
  class A untrusted
  class S,D,G openshell
  class W,I operator
  class T,U external
Loading

Solid arrows 1 to 7 are one request from the agent, in order. Dotted arrows A and B happen when a sandbox is launched; C and D are what the issuer provides. Red is untrusted, blue is OpenShell, green is the operator's identity system, and purple is outside both.

Two identities per sandbox

Identity Form Changes Purpose
Stable <prefix>/gateway/<gateway-id>/sandbox/<sandbox-id> Never, for the life of the sandbox The subject the token service authorizes
Launch <stable>/launch/<generation-id> When the gateway issues a new runtime generation: on create, start, resume, and automatic restart Proves this supervisor belongs to the current launch

The stable identity alone is not enough. A supervisor left over from an earlier start of the same sandbox would match the same issuer registration as its replacement. The launch identity is derived from the runtime generation the gateway already tracks, so nothing new is stored.

Who does what

Party Role
Gateway Derives both SPIFFE IDs, puts them in the launch bundle, verifies the assertions, performs the OAuth exchange, and holds the token-exchange subject.
Operator's issuer, such as SPIRE Registers both identities for the live supervisor and signs the JWT-SVIDs. OpenShell does not issue SPIFFE identities.
Driver Marks the supervisor with its launch ID so the issuer can tell it apart, and replaces the supervisor when a start names a different launch.
Supervisor Fetches two JWT-SVIDs from the Workload API socket, sends them to the gateway with its session JWT, and injects the returned access token.
Agent workload Makes plain HTTP requests through the proxy. It holds no socket, assertion, or token.

Grant flow

  1. The gateway puts the stable ID and the launch ID in the launch bundle.
  2. The driver starts the supervisor, marked with the launch ID.
  3. When the agent calls a service that a token grant covers, the supervisor fetches one JWT-SVID for the stable ID and the token service's audience, and one for the launch ID and urn:openshell:provider-grants:launch:<generation-id>.
  4. The gateway verifies both signatures against the Workload API trust bundle and requires the exact subject, one audience, and an unexpired token for each. It checks that the session is current and the provider is still attached.
  5. The gateway performs client_credentials or token_exchange with the stable JWT-SVID and returns only the access token. The supervisor injects it.

The gateway runs step 4 in full on a cache hit too, so a stopped sandbox or a superseded generation gets nothing from the cache.

One supervisor per sandbox at a time

A driver's start means "make this sandbox's supervisor carry the launch in this request". If the supervisor already carries it and runs, nothing changes. Otherwise the driver replaces the supervisor. Starts and stops keep their existing contract and stay idempotent, so the gateway's existing retry is enough. The compute driver API and the driver SDK do not change.

A supervisor from an earlier launch gets nothing: the gateway refuses every supervisor session except the current one, and its launch assertion does not match. The next start replaces it.

An earlier version of this change added an ordered start protocol, with a journal on the driver host, receipts, and replay, so that a launch identity could never start a second process. It was about nine tenths of the code. Two independent reviews found that the gateway's session check already stops a superseded supervisor, so that protocol was removed. What is given up: a late or reordered start can replace the current supervisor once, and after a failed start a launch identity can be carried by a second process, though never by two at once. If the stronger guarantee turns out to be required, it is a follow-up.

Evidence per runtime

  • Docker and Podman. The driver labels the supervisor container with the launch SPIFFE ID (openshell.ai/provider-launch-spiffe-id). An attestor that reads engine metadata can bind a registration to that one container. The workload container carries the label with an empty value, so an image or a sandbox template cannot set it. On rootless Podman the engine owner controls the labels, so issuance must be scoped to an engine owned by a trusted host account.
  • MicroVM. The supervisor is a host process and reads a Workload API socket on the driver host. Every supervisor has the same user and executable, so stock SPIRE Unix selectors cannot tell two of them apart. Per-sandbox identity on MicroVM needs an external attestor that binds each supervisor process to its launch. The driver does not provide one.
  • Kubernetes and other drivers. Kubernetes keeps the Sandbox resource UID registration through the Broker API. An extension driver opts in by advertising openshell.compute.provider-workload-identity, giving each dedicated supervisor a Workload API socket, marking the supervisor with its launch ID, and replacing the supervisor when a start names a different launch.

Configuration

[openshell.gateway.spiffe_workload_identity]
spiffe_id_prefix = "spiffe://example.org/openshell"
workload_api_socket_path = "/run/spire/agent.sock"

The mode needs a positive gateway_jwt.ttl_secs, an explicitly selected compute driver, and provider_spiffe_workload_api_socket in that driver's table. Preflight rejects the Kubernetes driver, a missing or non-Unix socket, and a supervisor endpoint that is neither HTTPS nor numeric loopback. Its messages carry no configuration values. Creating a sandbox needs only that the socket file exists; the issuer is first contacted on the first token grant. The user workflow does not change:

openshell --gateway my-gateway sandbox create --name provider-demo --provider cloud-api

Beyond token grants

Token grants come first because they are already an OAuth exchange in OpenShell, and an access token is what most APIs accept. The verified sandbox and launch binding is not specific to OAuth.

As more features need workload identity, reuse that binding for authentication and audit attribution. Give each consumer its own audience and policy. For example, a tool gateway could verify a credential scoped to that gateway and still apply per-tool authorization. Keep that integration and guest-held SVIDs outside this first token-grant slice.

Implementation

The change is a stack of eight pull requests, each reviewable alone: https://github.com/ai-openshell/openshell/stack/6060

Layer PR What it adds
1 #6050 The contract: one capability, the launch bundle fields, the identity check, the Configure flag
2 #6058 Supervisor fetches and presents the two assertions
3 #6059 Gateway puts both identities in the launch bundle and requires the capability
4 #6061 Gateway verifies the assertions, revalidates, caches, and limits grants
5 #6062 Docker driver support
6 #6063 Podman driver support, including supervisor replacement
7 #6064 MicroVM driver support
8 #6065 Gateway setting, preflight, and published docs

Only layer 8 adds the setting that turns the mode on. With the mode off, behavior equals main except for these:

  • A new Docker or Podman workload container carries the launch label with an empty value.
  • A standalone Docker or Podman driver that has provider_spiffe_workload_api_socket set runs one probe container at startup.
  • A MicroVM driver with a legacy guest TCP endpoint configured logs one warning.
  • Kubernetes brokered grants share the grant handler and gain two of its checks: a provider detached and reattached during an exchange rejects the in-flight token, and a credential driver's subject expiry caps how long a token is served.
  • A whitespace-only jwt_svid_audience now derives the issuer on the direct exchange path too.

Acceptance Criteria

  • With issuer registrations in place, two sandboxes on the same host use the same provider profile and yield distinct OAuth assertion subjects on Docker and Podman. Renewing a provider access token preserves its sandbox subject.
  • Stopping and starting a sandbox preserves its stable SPIFFE subject and gives the supervisor a new launch identity. The gateway denies grant requests from a stopped sandbox or a superseded generation, including cache hits, and rejects a mismatched sandbox identity or provider attachment.
  • At most one supervisor per sandbox runs at a time. A start that names a new launch replaces the supervisor, and a retried start finishes a replacement that failed.
  • Gateway preflight checks the selected local driver's socket settings. At runtime, a missing registration, a mismatched SVID, or an unavailable issuer yields a credential-free diagnostic and withholds the protected request.
  • The agent can make authorized requests through the proxy. The Workload API, JWT-SVIDs, and provider access token stay outside the agent workload.
  • Driver documentation explains the evidence an issuer must verify, the operator setup, how an extension driver can opt in, and the status of the legacy MicroVM TCP endpoint settings.

Known Limits

  • MicroVM has no in-tree attestor, so two VM supervisors cannot get distinct identities from stock SPIRE.
  • One gateway selects one compute driver, and the in-tree Docker, Podman, and MicroVM drivers each drive one engine or host. A fleet of machines under one gateway needs an extension compute driver that opts in, or Kubernetes with the Broker API mode.
  • No automated end-to-end test runs against a real issuer or token service. Tests use stubbed engines and signed fixtures. The docs give an operator-run verification procedure.
  • The operator registers a new launch identity each time a sandbox's generation changes and retires the old one. Until that happens, token grants for the sandbox fail. The stack ships no registrar.
  • A launch identity stays the same across a gateway restart, because the runtime generation does.
  • The gateway makes no revocation call to the token service. A token already attached to a request lives until it expires.
  • The mode stops credential theft. It does not stop misuse of access that policy allows.

Decisions for Maintainers

  • Whether "one supervisor per sandbox at a time" is enough, or a launch identity must be single-use. The single-use version was built and removed; it needs a journal on the driver host and ordered, replayable starts.
  • Whether the small driver contract in layer 1 needs an RFC.
  • Whether the two assertions should travel as one message on the grant request. It is a wire choice that is free to change before merge.
  • Whether a standalone Docker or Podman driver should qualify for the mode by itself when a socket is configured, or need an explicit flag.
  • Whether the stable ID should carry a workspace segment. Its shape becomes a contract with issuer registrations once the mode ships.
  • Who registers and retires the launch identity. A reference registrar would be a separate contribution.

Alternatives Considered

  • Configure only a Workload API endpoint. This lets a supervisor reach the identity service. Per-sandbox grants also need a registration and verifiable launch evidence so two supervisors using that endpoint get distinct subjects.
  • Federate OpenShell session JWTs directly. A token service could explicitly trust the OpenShell gateway as an issuer. SPIFFE grants let operators use an existing SPIFFE trust domain and its attestation policy. The session JWTs and the MicroVM guest TLS certificate already serve OpenShell's control channels.
  • Use an OpenShell provider or middleware extension. An extension can exchange or use a credential after it has a verified caller identity. Establishing the sandbox-to-launch binding at the trusted runtime boundary lets each extension rely on the same evidence and keep its own authorization rules.
  • Attest the VM from inside the guest. This can support guest-owned keys and independent guest or hardware attestation. Those requirements warrant their own design. Token grants can start with evidence from the trusted host.
  • Stable identity only, no launch identity. A restarted sandbox would leave its old supervisor with a registration that still matches, so the issuer could not tell the two apart.
  • A single-use launch identity. An ordered start protocol with a driver-side journal guarantees that a launch identity never starts a second process. It was built and removed, because the gateway's session check already stops a superseded supervisor and the protocol was most of the code.

Checklist

  • I've reviewed existing issues and the published docs
  • This is a design proposal, not a "please build this" request

Activity

  1. added theissue type on Nov 28, 2026
  2. changed the title [-]Support per-sandbox SPIFFE provider grants across compute drivers[/-] [+]Support per-sandbox SPIFFE identity for provider token grants across compute drivers[/+] on Nov 29, 2026
  3. changed the title [-]Support per-sandbox SPIFFE identity for provider token grants across compute drivers[/-] [+]Give each sandbox its own SPIFFE identity for provider token grants[/+] on Nov 29, 2026
  4. changed the title [-]Give each sandbox its own SPIFFE identity for provider token grants[/-] [+]Per-sandbox SPIFFE identity for provider token grants[/+] on Nov 29, 2026
  5. FrostGod commented on Nov 29, 2026

    @FrostGod
    Contributor

    @shiju-nv do we have an RFC for the feature, is it accepted by any of the maintainers,
    this to me seems like a quite an important change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions