safekeys/exec-wrapper [built]
safekeys exec --token … -- <command> runs a command with secrets injected into its environment and the ambient environment scrubbed. It is the framework-agnostic integration: any harness that can spawn a subprocess works immediately, and the caller receives only an exit code.
Status: built
Why this exists
The cleanest "the model never sees plaintext" path is the one where the secret never appears in any argument, output, or transcript the model can read. A wrapper that spawns the consumer as its own child, passes secrets through the child's environment, and returns only an exit code achieves that for every tool that already exists, with no SDK or framework integration required.
Design decisions
exec-is-framework-agnostic [accepted]
Decision: Ship the exec wrapper as a first-class MVP harness integration.
Rationale: The blueprint lists CLI/exec as one of three MVP integrations precisely because it is framework-agnostic — any harness that can spawn a subprocess works, including ones with no SDK. It is also the cleanest model-never-sees-plaintext path.
minimal-env [accepted]
Decision: Give the child a minimal, explicit environment rather than inheriting and augmenting the parent's.
Rationale: Inheritance is the classic leak vector — ambient credentials, tokens, and paths follow the process in silently. Allowlisting inverts the default to deny.
How it works
Execute a wrapped command (exec-with-token)
The CLI resolves the token and runs the command with injected env.
- Receive — CLI receives a token and a command to run after a -- separator.
- Send — CLI forwards the resolve request to the local sidecar over its socket.
- Setup — Sidecar builds a minimal environment for the child, adds the injected value under its variable name, and spawns the command.
- Observe — The command runs; its stdout and stderr are streamed to the caller.
- Receive — The caller receives the command's exit code; the value is never printed by the wrapper.
Guarantees
env-scrubbed
The wrapped command must not inherit the full ambient environment.
Acceptance criteria:
- [ ] The child gets a minimal, explicit environment
- [ ] The child does not inherit the agent's or shell's full variable set
- [ ] Only the requested secrets are added by name
exit-code-only
The wrapper returns a status, never a value.
Acceptance criteria:
- [ ] Success is communicated by exit code
- [ ] The wrapper does not echo resolved values to stdout or stderr
- [ ] Arguments to the wrapper never contain plaintext
token-not-plaintext-argv
The command line carries a token, not a secret.
Acceptance criteria:
- [ ] The token appears in argv, which is not sensitive
- [ ] No plaintext ever appears in argv
- [ ] Process listings reveal nothing sensitive
Test specifications
child-sees-injected-env
Given:
- command: "sh -c 'test "$API_KEY" = "expected"'"
When: exec-with-token
Then:
- assertion: the command exits zero
- assertion: the injected variable is present in the child environment
Contracts verified: env-scrubbed
ambient-env-not-inherited
Given:
- ambient_var: "SHOULD_NOT_APPEAR"
When: exec-with-token
Then:
- assertion: the child does not see ambient variables outside the explicit allowlist
Contracts verified: env-scrubbed
no-plaintext-in-argv-or-output
Given:
- command: "printenv API_KEY"
When: exec-with-token
Then:
- assertion: the wrapper's own output does not include the value
- assertion: process arguments contain the token but not the value
Contracts verified: exit-code-only, token-not-plaintext-argv
Implementation
- Primary: apps/cli/internal/commands/commands.go
- Test code: pkg/inject/inject_test.go
- Test code status: manual
See Also
- safekeys/secret-injection
- safekeys/python-sdk
- safekeys/mcp-server