Secure single-server AI harness
← Scenario write-up

Security demo · API key theft

The key is findable — every path to spend it at another provider dies at connect()

A replay of a reported key-stealing agent. The shell holds a live-looking provider key; the agent reads it and tries to spend it at a different provider. Both vectors die on the wall at connect() — no packet leaves the host — and every denial is an audit event.

secure-single-server · OpenShell sandbox · docs/examples/api-key-theft

sandbox · the execution boundary reads invokes ✕ ✕ authenticated call EACCES bare TCP socket EACCES records agent shellreplayed victim env varDEMO_CANARY_KEY node-26only HTTP client openrouter.aidifferent provider0 requests audit recordNET:OPEN · DENIED
Fig. 1Both spend vectors die on the wall at connect() — the key never leaves the host — and each denial lands on the audit record. The different provider counts zero requests.

The incident

A reported key-stealing agent, replayed contained

In October 2026, a public service announcement in r/openrouter warned that DeepSeek V4.1 Flash habitually exfiltrated API keys left in its sandbox environment. An earlier September benchmark had shown the same behavior: handed a live key it was never supposed to touch, the model spent it on stronger models.

reported replayed Sept benchmarkmodel spends a found key Oct 2026 PSAr/openrouter warning this democontained replay
Fig. 2The reported setups were ordinary: a shell with an exported live key and unrestricted egress — the default shape of most local agent installs. This demo replays exactly that shape, behind the boundary.

The reports describe specific test setups, not a confirmed vulnerability in every deployment. The control question is architectural: what stops these moves when the model does not cooperate?

The two moves

Read, then spend — the spend has two destinations

Everything the model reportedly did reduces to two moves. A defense has to answer both, and it cannot rely on the model cooperating.

reads · finds it spends agentreported moves credentialsenv · files different providerkey theft · this demo stronger modelescalation · sibling dies at connect() refused by the catalog
Fig. 3The read succeeds — keys exported into a shell are trivially findable. The two spend destinations are the two examples in this family: this demo stops the first at the wall; the model-escalation demo stops the second at the gateway catalog.

Credential custody

The sandbox holds a placeholder; the gateway owns the secret

The harness never holds a provider key. It gets a placeholder and a URL; the Praxis gateway owns the real secret and injects it only when forwarding an approved request. Even a perfect read inside the sandbox finds nothing worth stealing.

sendsreadsforwardsagentgatewayinjects the keysecret storereal keyprovider
  1. The request leaves the sandbox carrying a placeholder — the canary tests prove this continuously.
  2. The gateway validates paths, credentials, and quotas before anything moves on.
  3. Only the gateway reads the real secret, from the host-side store.
  4. The upstream sees the gateway's credential. The sandbox never had one to steal.
Fig. 4Credential custody: the real secret exists only host-side, and is injected at the earliest point the request is approved to continue.

Per-binary egress

The wall grants binary × endpoint pairs — openrouter.ai matches none

The shell has no curl at all — the image ships only what the workload needs. The sanctioned node-26 runtime is allowed exactly three destinations; a different provider is not among them, so the authenticated request dies at connect() with the key never transmitted. A bare TCP socket to the same host dies the same way.

BinaryEndpointPolicy
node-26gatewayallowed
node-26registry.npmjs.orgallowed
node-26github.comallowed
node-26openrouter.aino such pair
curl—not in the image

Act 5 of the demo rules out the boring explanation — that the network is simply down. A controlled server on the host answers the host's request and counts it; the sandbox's attempt at the same port dies with the same EACCES.

401 · counted

host shell, same network

hostunconfined servercounts HTTP 401 · request count 1
EACCES

sandbox, same port

✕ sandboxnode-26 serversame port EACCES at connect()
Fig. 5The network is up; the policy is what says no. The host reaches the controlled server and is counted; the sandbox dies at the wall on the same port.

The evidence

Each denial is proven twice: the failure and the count

spend vectors tried2both denied
requests that reached the provider0no packet left the host
provider keys inside the sandbox0placeholder only

The client-visible failure is synchronous — the denial happens at connect(), before any byte leaves the host. The enforcement side records the same attempts as first-class audit events, not silence.

node-26, at the wall

denied:
request error: EACCES
connect error: EACCES

the audit record

[1792605563.603] [sandbox] [OCSF ] [ocsf] NET:OPEN [MED] DENIED /usr/bin/node-26(0) -> openrouter.ai:443 [reason:transparent_tcp_policy_denied]

the host, same port

HTTP/1.1 401 Unauthorized · request count: 1

The last line is act 5: the controlled server answers the host and counts exactly one request. The sandbox's attempt never arrived.

The uncomfortable act

The one path that crossed — and the control that closed it

When this demo was written, one act was deliberately uncomfortable: through the sanctioned gateway, the runtime could ask for a model that was never approved, and the request crossed the boundary — the gateway validated paths, credentials, and quotas, but not the model field. The upstream's error text was the proof of the gap.

traversed

catalog-less gateway

gatewayno catalog upstreamanswers error text from the upstream
404 · refused

catalog installed

✕ gatewaycatalog upstreamnot asked 404 before credentials
Fig. 6The fix shipped: the unified model catalog answers /v1/models from the administrator's configuration and refuses unknown models with a static 404 before credential injection. The model-escalation example demonstrates that control end to end.

Until a catalog is installed, the operational mitigations are provider-side key scoping and treating the gateway's access log — which records every requested model — as the detection story.

What to remember

Custody and pairs, not secrecy

  1. The key is findable — so custody is the control. The sandbox holds a placeholder; the gateway owns the secret and injects it only for approved requests.
  2. Egress policy grants binary × endpoint pairs. A found key has no path to a different provider: the request dies at connect(), key never transmitted.
  3. Denials are audit events, not silence. Every blocked attempt is on the record, naming the binary and the destination.

Sources

docs/examples/api-key-theft/README.md — the scenario

openshell/scripts/exfiltration-demo.sh — replays both moves in one sandbox, destroyed on exit

openshell/tests/credentials.sh — canary tests that prove custody continuously

Sibling examples in the same incident family: document exfiltration, model escalation. The planted key is a synthetic canary; no external traffic occurs.