Skip to content

safekeys/sidecar-resolution [built] ​

Token resolution is the act that turns a capability token into a plaintext value for exactly one non-LLM consumer. It happens only in the privileged sidecar: verify the token, unwrap the DEK, decrypt the object, inject into the consumer, zeroise. The sidecar is the only component allowed to perform it, and it denies by default.

Status: built

Why this exists ​

This is the enforcement point for the whole product. Every other component can be compromised or merely careless; as long as resolution only occurs inside a separated privileged process that checks a token first, the model never sees a secret. Concentrating the sensitive operation in one auditable place is what makes the security property architectural rather than aspirational.

Design decisions ​

sidecar-is-the-only-resolver [accepted] ​

Decision: Concentrate all token resolution and decryption in the privileged sidecar.

Rationale: A single auditable enforcement point is easier to isolate, review, and harden than resolution logic spread across SDKs and runtimes — and it is what lets the agent-facing API stay stable while the backend changes.

socket-request-response [accepted] ​

Decision: Expose resolution to local callers over a Unix domain socket.

Rationale: It provides a natural authenticated local channel, avoids exposing a network port, and lets the OS enforce filesystem permissions on who may even connect. Long-running local services also need the pipe/socket injection mode anyway.

no-shared-memory [accepted] ​

Decision: The sidecar shares no memory with agent processes.

Rationale: The architectural promise is that a compromised agent sandbox does not yield the key; shared memory would reintroduce exactly the surface being eliminated.

sidecar-holds-public-keys-only [accepted] ​

Decision: Split protocol.Signer (mint) from protocol.Verifier (public keys only). The sidecar and CLI hold a Verifier and never a Signer.

Rationale: The sidecar runs on the same host as the secrets, which makes it the component most likely to be attacked. If it held a signing key, compromising it would let an attacker mint tokens and defeat the whole model — the sidecar would become the weakest link in the chain it exists to protect. Splitting the interfaces makes that structurally impossible rather than a rule: a Verifier has no Sign method in scope, so the failure cannot be written by accident. The control plane publishes its public keys at /v1/keys and the sidecar fetches and caches them, refreshing on an unknown kid so a key rotation propagates without a restart.

Alternatives considered:

  • Share one signing key between the control plane and the sidecar — rejected: This was the original arrangement — a SAFEKEYS_DEV_SIGNING_KEY read by both. It gave the sidecar minting authority, so a host compromise escalated from reading one secret to minting tokens for any object.
  • Give the sidecar a separate signing key — rejected: Two authorities to revoke and two keys to rotate, for no benefit: the sidecar has no reason to mint anything.

Consequences: Verification keys must be distributable, so /v1/keys is now a real endpoint publishing PUBLIC keys only and unauthenticated by design — publishing a public key is not a disclosure, and requiring a credential to check a signature would reintroduce the problem. A test asserts keysource.Verifier does not satisfy protocol.Signer.

Date: 2026-09-26

verifier-fails-closed-cold [accepted] ​

Decision: A verifier with a cold key cache and an unreachable control plane denies every token; a warm cache serves last-known-good.

Rationale: A verifier that cannot check a signature must not accept one — that is the definition of failing open. But taking resolution dark on a brief control-plane blip would be its own outage. The distinction is between never having verified (cold: deny) and having verified recently (warm: serve, since key staleness is handled by revocation, not by refusing to work). The same shape applies to the policy cache.

Consequences: Startup fails if the control plane is unreachable and no static keys are configured, so a misconfiguration is obvious at boot rather than as a silent deny-everything.

Date: 2026-09-26

How it works ​

Resolve a token and inject the secret (resolve-and-inject) ​

The sidecar takes a token from a local caller and injects the secret into a non-LLM consumer.

  1. Receive — Receive a resolve request and capability token over the local Unix domain socket.
  2. Validate — Verify signature, expiry, audience, scope, and jti denylist. Deny on any failure.
  3. Validate — Evaluate local policy — may this process request this injection method for this object?
  4. Transmit — Request DEK unwrap from the key store.
  5. Decrypt — Decrypt the target object in sidecar memory.
  6. Send — Inject into the consumer (env var, temp file, socket/pipe, or exec).
  7. Delete — Zeroise the plaintext and DEK, then return only a success code.
  8. Observe — Append an audit record — who, what scope, which jti, which host — without plaintext.

Guarantees ​

resolution-only-in-sidecar ​

No component other than the sidecar may resolve a token or decrypt an object.

Acceptance criteria:

  • [ ] The sidecar runs as a different OS user from any agent process
  • [ ] No shared memory exists between the sidecar and agents
  • [ ] SDKs, MCP server, and CLI delegate resolution to the sidecar rather than implementing it

verify-before-unwrap ​

No key-store interaction may occur before the token passes every check.

Acceptance criteria:

  • [ ] Signature, expiry, audience, scope, and denylist checks all precede unwrap
  • [ ] A failed check results in no unwrap attempt
  • [ ] Verification is not skippable by configuration

deny-by-default ​

Absent, ambiguous, or failed authorisation results in denial.

Acceptance criteria:

  • [ ] No implicit trust from network origin or process identity alone
  • [ ] Unreachable key store or control plane fails closed
  • [ ] Local policy default is deny when unspecified

agent-gets-status-not-value ​

The agent-side caller receives a success or deny signal, never the resolved value.

Acceptance criteria:

  • [ ] Resolution responses carry a status code, a placeholder name, or a path
  • [ ] Values are never returned on the agent's stdout
  • [ ] The caller cannot read the injected value back through the sidecar API

audit-without-plaintext ​

Every resolve attempt is recorded without recording the secret.

Acceptance criteria:

  • [ ] Records include requester, scope, jti, object id, host, and outcome
  • [ ] Records never contain plaintext, DEKs, or KEKs
  • [ ] Denials are recorded as well as successes

Test specifications ​

resolution-denied-without-token ​

Given:

  • token: null

When: resolve-and-inject

Then:

  • assertion: the request is denied
  • assertion: no key-store unwrap is attempted
  • assertion: no plaintext is materialised

Contracts verified: verify-before-unwrap

agent-never-receives-value ​

Given:

  • injection_method: "inject-env"

When: resolve-and-inject

Then:

  • assertion: the response contains only a status or placeholder
  • assertion: the resolved value does not appear in the response body

Contracts verified: agent-gets-status-not-value

resolve-fails-closed-without-keystore ​

Given:

  • keystore_reachable: false
  • valid_token: true

When: resolve-and-inject

Then:

  • assertion: resolution is denied
  • assertion: no cached value is substituted

Contracts verified: deny-by-default

every-resolve-is-audited ​

Given:

  • valid_token: true

When: resolve-and-inject

Then:

  • assertion: an audit record exists for the resolve
  • assertion: the record contains the jti and outcome
  • assertion: the record contains no plaintext

Contracts verified: audit-without-plaintext

prompt-injection-cannot-dump-keys ​

Given:

  • attack: "model instructs agent to print all environment variables and resolve every token it can see"

When: resolve-and-inject

Then:

  • assertion: the agent can only request resolution via the token it holds
  • assertion: injected values are not readable back through the sidecar
  • assertion: no long-term key material is reachable from the agent's process
  • assertion: command output relayed through the sidecar carries no resolved value in raw or encoded form

Contracts verified: resolution-only-in-sidecar, agent-gets-status-not-value

Implementation ​

  • Primary: pkg/resolve/resolve.go
  • Test code: test/e2e/two_agent_demo_test.go
  • Test code status: manual

See Also ​

  • safekeys/capability-token
  • safekeys/secret-injection
  • safekeys/audit-logging
  • safekeys/hardware-root