kosa8 / Integrations / Codex CLI
Integration · Codex CLI · Last checked: November 2026
Run Codex CLI in a microVM sandbox
kosa8 agent run codex starts OpenAI's Codex CLI in a microVM of its own. Codex sees one folder at /work, reaches registry.npmjs.org and, through a broker on your computer, api.openai.com, and holds a placeholder instead of your OpenAI key. Because the VM is the boundary, Codex can run with danger-full-access inside it. kosa8 prompt -a codex runs one task headless with codex exec.
01How it works
The codex kit boots node:22-alpine with 4 vCPUs and 4096 MB and installs @openai/codex 0.162.1, checked against a pinned digest. The sandbox gets OPENAI_BASE_URL pointing at a broker on your side and a placeholder in OPENAI_API_KEY; the broker adds the real key only to requests to api.openai.com. The kit also installs kosa8's hook as a managed Codex PreToolUse hook in the sandbox.
Codex's own sandbox needs kernel features the kosa8 guest does not give it, so the headless kit runs codex exec --dangerously-bypass-approvals-and-sandbox and the microVM is the boundary instead. OpenAI's reference says to use that flag only inside an externally hardened environment.
02Steps
Install kosa8 and start its daemon. Sandboxes run on an Apple silicon Mac, an x86-64 Linux machine with KVM, or Windows 11 through WSL2 (preview).
kosa8 doctorreports anything missing.Keep your OpenAI key on your computer. kosa8 reads it when the sandbox starts and hands it to the broker, not to the sandbox.
Preview the plan. The dry run prints the folder, the network and the credential route, and starts nothing.
Run Codex in the microVM. Everything after the kit name is passed to Codex.
Or give it one task, headless. A fresh sandbox runs
codex execon the task and is removed when it finishes.Check where it went. Every brokered request, allowed or refused, is in the audit log.
kosa8 sandbox egressshows a running sandbox's rule and refusals.Or keep Codex local and give it cloud sandboxes. Add kosa8 Cloud's MCP server to
~/.codex/config.toml. Codex stays on your machine; only the commands it sends to the sandbox tools run in cloud microVMs.[mcp_servers.kosa8-cloud] url = "https://api.kosa8.com/mcp" bearer_token_env_var = "KOSA8_API_KEY"
03Settings
| Setting | In the codex kit | Change it with |
|---|---|---|
| Folder | the current directory, at /work | -w DIR |
| Network | registry.npmjs.org; api.openai.com through the broker | --no-network denies all network access; egress_allow in your own kit |
| Credential | OPENAI_API_KEY, brokered; OPENAI_BASE_URL set to the broker | the variable on your computer |
| Codex | @openai/codex 0.162.1, digest-checked | your own kit |
| Image and size | node:22-alpine, 4 vCPUs, 4096 MB | image, cpus, mem_mb in your own kit |
| Headless command | codex exec --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox TASK | kosa8 prompt -a codex |
| Tool-call hook | kosa8's managed PreToolUse hook | kosa8 mcp asks, kosa8 mcp approve |
| Skills | $HOME/.agents/skills in the sandbox | --skill NAME |
| After it exits | the sandbox is removed | --keep |
kosa8 agent init codex writes the built-in kit to ~/.kosa8/kits/codex.yaml for you to edit.
04What this protects against, and what it does not
What it protects against
- Codex reaching files outside the folder you name: the rest of your disk is not in the VM.
- Your OpenAI key being read or sent elsewhere: the sandbox holds a placeholder.
- Requests to any host but npm and the OpenAI API: refused on your side of the boundary, and logged.
danger-full-accessreaching your user account: inside the VM it reaches one microVM, not your computer.
What it does not
- Anything in the shared folder, including
.git. Commit before you start. - What Codex sends to the hosts it can reach, including your code sent to the model.
- Spending your key through the broker: anything in the sandbox can use the placeholder for requests to api.openai.com.
kosa8 limits what a hijacked agent can reach; it does not detect or prevent prompt injection. SOC 2 Type II is in progress; there is no SOC 2 report and no external penetration test yet.
05Questions
Why does the headless kit bypass Codex's own sandbox?
Codex's own sandbox needs kernel features the kosa8 guest does not provide, so the kit runs codex exec with --dangerously-bypass-approvals-and-sandbox and makes the microVM the boundary. OpenAI's reference says to use that flag only inside an externally hardened environment, which is what the VM is for.
Does Codex see my OpenAI API key?
No. The sandbox gets a placeholder in OPENAI_API_KEY and an OPENAI_BASE_URL that points at a broker on your computer, which adds the real key only to requests to api.openai.com.
Can Codex reach the internet from the microVM?
Only registry.npmjs.org by name, and api.openai.com through the broker. Every other host is refused on your side of the boundary and written to the audit log. --no-network denies all network access, overriding the kit.
Can I give Codex sandboxes without running Codex inside one?
Yes. Add kosa8 Cloud's MCP server to ~/.codex/config.toml with url https://api.kosa8.com/mcp and bearer_token_env_var KOSA8_API_KEY. Codex then stays on your machine, and only the commands it sends to the sandbox tools run in cloud microVMs.
Is Codex's work kept when the sandbox ends?
Changes in the shared folder stay, because it is your project directory. The sandbox itself is removed when Codex exits, unless you pass --keep.
06Get started
The reference for this page, with every option, is in the kosa8 docs: Codex CLI in a microVM.
To try a kosa8 sandbox without installing anything or making an account, kosa8.com/try runs code in a fresh sandbox with no outbound network: 15 minutes of run time free per 24 hours, each run up to 60 s.
Try free with no account. Starter is free with no card; plans from $29 a month.
Last checked: November 2026 · Updated 2026-11-29