quiet robotBook a call

Sandboxes

Keys, identity and the outbound check

Let a sandbox use API keys it never holds, prove which sandbox is calling your services, and check every call on its way out.

View as Markdown

Sandboxes is in early access. It is free to try, some parts are still in testing, and details may change. Sign up free

Not live yet

Built and working in our tests. It hasn't been tried on the hosted service yet.

An agent that holds an API key can leak it. A prompt injection can ask it to print its environment, a snapshot can copy the key, or a bad package can read it. With Sandboxes the key stays with us, and the sandbox gets a stand-in that's useless anywhere else.

Keys that never enter the sandbox

1. Save the key once, with the hosts it may be sent to. Do this under Policy → Secrets in the dashboard, or through the API:

Terminal
curl -s -X POST "$QR_BASE_URL/api/v1/secrets" -H "Authorization: Bearer $QR_API_KEY" \
  -d '{"name":"OPENAI_API_KEY","value":"sk-...","hosts":["api.openai.com"]}'

The value is stored encrypted and is never shown again. Listing your secrets shows their names, hosts and when each was last used.

2. Start a sandbox that may use it. Secrets need egress mode allowlist or open. In allowlist mode the gateway's address is added to the list for you.

TypeScript
const sbx = await qr.create({ secrets: ["OPENAI_API_KEY"], egress: { mode: "allowlist", allow: [] } });

Inside the sandbox, OPENAI_API_KEY holds a stand-in such as qrs.sbx_…, not the key. QR_GATEWAY_URL holds the gateway's address.

3. Send calls through the gateway. Use $QR_GATEWAY_URL/<host>/<path>, with the stand-in where the key goes, in a header or the query string. Most SDKs only need their base URL changed:

Terminal
export OPENAI_BASE_URL=$QR_GATEWAY_URL/api.openai.com/v1
python3 my_agent.py   # the OpenAI SDK sends the stand-in; the gateway adds the key

The gateway checks the stand-in, adds the real key outside the sandbox and forwards the call to https://<host>/<path>. The answer comes back as it was, streaming included.

The rules

  • A key only goes to its own hosts. If any stand-in in a call isn't allowed to go to that host, the call is refused (403). A call with no stand-in is refused too, so the gateway can't be used to get around your egress rules.
  • A stand-in only works for its own sandbox, and only while that sandbox runs. It stops working when the sandbox stops or the secret is deleted. A new value takes effect on the next call.
  • Every use is on the record as secret.used in the audit log, with the host, method, path and status.
  • Request bodies can be up to 4 MB.
  • A service that echoes your request headers back would show the key to the sandbox, so list only hosts you trust with the key.

Identity for each sandbox

Your own services can know exactly which sandbox is calling, and who started it, without a shared password inside the VM.

TypeScript
const sbx = await qr.create({ identity: { hosts: ["api.yourcompany.com"] }, egress: { mode: "allowlist", allow: [] } });
// inside: curl -H "Authorization: Bearer $QR_IDENTITY_TOKEN" $QR_GATEWAY_URL/api.yourcompany.com/jobs

The gateway replaces QR_IDENTITY_TOKEN with a fresh token (a JSON Web Token, EdDSA) that is valid for five minutes and only for that host. It holds:

ClaimValue
subsandbox:<id>
audthe host the call went to
orgyour organization's id
sandboxid, name and template
started_bythe person (email) or API key (name) that started the sandbox

Check it with our public key at GET /api/v1/identity/jwks.json. Any JWT library that supports EdDSA can do this.

The outbound check

You can put a check of your own in front of every call that leaves through the gateway: a filter for leaked data, a prompt-injection scanner, or your own approval service. Set it under Policy → Outbound check. Only owners and admins can set it, and API keys can't change it.

Before each call, we POST this to your check:

JSON
{
  "sandbox": { "id": "sbx_…", "name": "invoice-bot" },
  "host": "api.openai.com", "method": "POST", "path": "/v1/chat/completions", "query": "",
  "headers": { "authorization": "Bearer qrs.sbx_…" },
  "body": "{\"model\": …}", "bodyEncoding": "utf8", "bodyBytes": 812, "bodyTruncated": false
}

Headers carry stand-ins, never real keys, and the body is the first 64 KB. Your check answers {"allow": true} to let the call through, or {"allow": false, "reason": "…"} to refuse it. The reason is shown to the sandbox and written to the audit log.

It fails closed. No answer within 3 seconds, an error, or anything other than "allow": true refuses the call.

Each request carries X-QR-Timestamp and X-QR-Signature: sha256=<hex>, an HMAC-SHA256 of timestamp + "." + body made with the signing secret shown when you saved the check. Check the signature, and reject old timestamps.