The problem
If you run an AI coding agent in a sandbox, there's one thing that's easy to overlook: the agent's own login token.
When you type /login in your coding agent from inside the sandbox, the OAuth token ends up stored in the sandbox. That means that if
the agent gets manipulated by a prompt injection, it can read that token and exfiltrate it to an attacker-controlled website.
nono has a nice solution to this problem called sandboxed OAuth logins. In this post, I'll show how to set it up for GitHub Copilot CLI and a Business plan (not with an invididual subscription).
It's credential injection but in reverse
Regular credential injection works in one direction. You already have a secret, say an API key. You put a placeholder in the sandbox and the proxy swaps it for the real secret on outgoing requests. The secret is scoped to the hosts it's meant for: if a prompt-injected agent sends the placeholder to attacker.com, the proxy blocks it.
This doesn't help for
/login, because the secret doesn't exist yet. The OAuth provider creates it during the login and sends it back in a
response, straight into the sandbox.
nono also handles that direction. Its proxy watches the responses of the login endpoints and captures the real tokens as they come back. The agent only receives placeholders. From then on it's regular credential injection: the proxy swaps the placeholder for the real token, but only on requests to approved hosts.
Why it's so convenient
This is super useful to get started with a sandboxed agent. Without it, you have a few subpar options:
- Log in inside the sandbox and leave the token there, where a manipulated agent can read it.
- Log in outside the sandbox and copy the token into the sandbox, which exposes it just the same.
- Log in outside the sandbox and set up regular credential injection manually with the token you got. This is safe, but it's a hassle, and you have to redo it when the token changes.
With nono, you start the agent in the sandbox, type /login like you normally would, and that's it.
Very few sandboxing tools support this. In my comparison, only nono and Docker Sandboxes did, and I only tested it with nono.
The profile
This setup is for GitHub Copilot CLI with an enterprise account on a dedicated GitHub Enterprise Cloud
instance at example.ghe.com (replace it with your own domain).
Note that Copilot CLI must be installed on the host first. That's just how nono works: it uses OS-level sandboxing (Landlock on Linux, Seatbelt on macOS) to restrict a process running on your machine. Tools that run the agent in a microVM from an OCI image, like Docker Sandboxes, ship the agent inside the image, so there's nothing else to install on the host.
Here's the profile I used, saved as ~/.config/nono/profiles/copilot-custom.json:
{
"extends": null,
"meta": {
"name": "copilot-custom",
"version": "1.0.0",
"description": "Copilot CLI profile with example.ghe.com /login support"
},
"network": {
"block": false,
"allow_domain": [
"example.ghe.com",
"copilot-api.example.ghe.com",
"api.github.com",
"api.githubcopilot.com"
]
},
"credential_providers": {
"github_copilot_ghe": {
"type": "oauth_capture",
"token_endpoints": [
{
"host": "https://example.ghe.com",
"path": "/login/device/code",
"response_fields": [
{ "path": "access_token", "kind": "opaque" },
{ "path": "refresh_token", "kind": "opaque" },
{ "path": "id_token", "kind": "opaque" }
],
"request_body": "auto",
"request_nonce_fields": ["refresh_token"]
},
{
"host": "https://example.ghe.com",
"path": "/login/oauth/access_token",
"response_fields": [
{
"path": "access_token",
"kind": "opaque",
"format": "gho_deadbeef{}"
},
{ "path": "refresh_token", "kind": "opaque" }
],
"request_body": "auto",
"request_nonce_fields": ["refresh_token"]
}
],
"api_hosts": [
"https://api.example.ghe.com",
"https://copilot-api.example.ghe.com"
],
"inject_header": null,
"credential_format": null,
"credential_store": {
"type": "file_json",
"path": "~/.github-copilot-ghe/auth.json",
"phantom_fields": ["tokens.access_token", "tokens.refresh_token"]
},
"helpers": null
}
},
"credential_routes": [
{
"name": "github_copilot_ghe_oauth",
"provider": "github_copilot_ghe",
"env_var": null,
"base_url_env_var": null,
"endpoint_policy": null,
"upgrades": []
}
]
}
What it does
network.allow_domainonly allows outgoing traffic to the GHE instance and the Copilot API hosts.- The
oauth_captureprovider watches the login endpoints. When the realaccess_tokenandrefresh_tokencome back, nono keeps them outside the sandbox. formatis the placeholder the agent gets. Copilot CLI refuses tokens that don't start withgho_, so the placeholder must look like a valid one.api_hostsare the only hosts where the placeholder gets replaced by the real token.
Running it
nono run --profile copilot-custom --allow-cwd -- copilot
--allow-cwd gives read/write access to the current directory only. Then run /login inside Copilot CLI and
go through the device code flow as usual. If something gets blocked, nono suggests profile changes when you exit.