Sandbox Credential Isolation
In this article
- Name the three ways a real key inside a sandbox leaks out through generated code.
- Configure a masked credential so the code holds a placeholder and the proxy adds the real key only for one host.
- Explain why the proxy must end TLS with its own certificate authority to make the swap.
- Check after a run that no real key remains in the environment, files or logs, and that other hosts are refused.
Overview
The script your assistant writes has to send its result to an internal service, and that service wants an API key. The obvious move is to put the key in an environment variable and let the script read it. But you did not write that script, and anything the script can read, it can also print, save or send.
You will see the three ways a key escapes from a sandbox (the isolated container where generated code runs), then set up the safer shape: the code only ever holds a stand-in value, and a proxy (a server outside the sandbox that every outgoing request passes through) swaps in the real key for one named host. You will also check, after the run, that the real key appears nowhere it should not.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- Where a key leaks
- A placeholder inside, the key outside
- Why the proxy must read HTTPS
- The safe run
- Scanning after the run
- What the swap does not stop
- The rule at work
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions