A Codex runner does not need your production database password to fix a unit test. Yet launching it from an administrator's shell can quietly give it credentials exported for an unrelated job. On an always-on VPS, that mistake can survive long after the SSH session ends.
We treat Codex secrets as a credential-routing problem, not just a prompt-writing problem. This guide focuses on what spawned shell commands inherit, how to verify that boundary without exposing a real token, and which access paths remain outside it. It complements our sandbox guide; it does not replace one.
Codex secrets: separate authentication from tool credentials
There are three different credential paths. Mixing them makes both incident response and billing harder to understand.
| Credential path | Purpose | Our default |
|---|---|---|
| Codex sign-in | Lets Codex access the account's available models | Use the supported account flow; protect credential storage |
| Repository and test tools | Fetch code or reach a test-only service | Grant only the repository and environment needed |
| Publication | Merge, release, or change production | Keep credentials outside the coding runner |
A ChatGPT sign-in is not a reason to export an OpenAI API key into every test process. Likewise, keeping a deployment token out of the prompt is insufficient if a shell can read it from the environment, a file, an SSH agent, or a credential helper.
Our source is OpenAI's advanced configuration reference. The examples below concern local Codex CLI execution on your VPS, not the environment policy of hosted Codex tasks. Check the installed version and effective configuration before rollout; setting names and defaults can change.
Run your first agent in about 3 minutes
Install the Office Claws CLI, connect your Contabo account and Codex subscription, and your agent gets its own VPS and a desk in the office.
curl -fsSL https://officeclaws.com/downloads/install.sh | sh$4.99/mo + your own Contabo VPS · keys stay in your keychain
Reduce the environment passed to shell commands
OpenAI documents shell_environment_policy as controlling variables passed to spawned commands. It is not a filter on everything the Codex process itself can access. Put the following starting point in the runner account's user configuration, normally ~/.codex/config.toml, adapting an existing table rather than creating duplicate TOML tables:
[shell_environment_policy]
inherit = "core"
ignore_default_excludes = false
[shell_environment_policy.filters]
"AWS_*" = "exclude"
"AZURE_*" = "exclude"
"DEPLOY_*" = "exclude"
"OFFICECLAWS_SECRET_CANARY" = "exclude"This reduces inheritance and explicitly excludes example credential families. It is not a complete list of secret names. In the current documentation, ignore_default_excludes defaults to true: automatic removal of names containing KEY, SECRET, or TOKEN is therefore not something we assume. Setting it to false enables those default exclusions.
The order matters: automatic exclusions, custom exclusions, explicit set values, then the include-pattern allowlist. A value in set can restore an excluded variable. When any filter uses include, only matching names survive the final allowlist; an include does not itself restore a removed value. Do not mix the legacy exclude or include_only arrays with the newer filters table in the same layer.
inherit = "none" is stricter but may require deliberately rebuilding the environment your tools need. Even core can break a build that relied on interactive-shell setup. Start with a reviewed fixture, not an overnight production job. Review higher-priority project and CLI settings as described in our configuration profiles guide.
Verify with a dummy canary, not an environment dump
Use a disposable repository with no credentials, under the intended unprivileged runner account. Export a deliberately fake marker before launching Codex:
export OFFICECLAWS_SECRET_CANARY=not-a-real-secretAsk Codex to run this exact check through its shell tool, without printing other variables:
if [ "${OFFICECLAWS_SECRET_CANARY+x}" = x ]; then
printf 'FAIL: canary inherited\n'
exit 1
else
printf 'PASS: canary absent\n'
fiRun the check first with your normal SSH launch and then through the actual service or scheduler launcher, exporting the fake marker in that launch environment too. A scheduler often starts with fewer variables, so a pass without a marker in the parent environment does not test the filter. Inspect the executed command and tool result; a model saying it complied is not evidence.
Keep the CLI version, reviewed configuration revision, launch method and pass/fail result. Never attach env, printenv, shell tracing, an authentication file or an entire service environment to a support ticket. Also test a normal fixture build: blocked secrets and working tools are separate acceptance criteria. Repeat after upgrades or launcher changes.
This proves only that the tested shell invocation did not inherit that marker. Shell startup files, tool wrappers and credential helpers can introduce other values afterward. Avoid login-shell initialization that loads administrator credentials; inspect the actual execution path rather than trusting a clean interactive terminal.
Close the file, integration and deployment paths
An environment filter does not hide .env files, cloud credential directories, readable backups or the runner's Codex authentication storage. A read-only filesystem policy prevents writes; it does not make all readable secrets confidential. Use a dedicated OS identity, restrict readable data, and avoid giving the coding account root, unrestricted sudo, a forwarded personal SSH agent or the host Docker socket. File permissions do not isolate secrets from another process running as the same user.
MCP servers, hooks and connected apps have their own launch environments and permissions. Review them independently; the shell policy is not proof that those integrations have lost access. Treat logs and agent reports as potentially sensitive output and restrict retention and sharing. A secret scanner can catch some accidental output, but it does not undo disclosure. If a real token appears in a report or transcript, revoke or rotate it, inspect its use, and follow your incident process; deleting the visible line is not enough.
We keep release credentials in a separately authorized publication step. The runner produces a diff and test evidence; a human or approved release system decides whether to ship. That architecture remains useful even when an agent finishes successfully.
Office Claws provides desktop and CLI management for Codex agents on your own Contabo VPS with private Tailscale connectivity. The environment policies and tests here are operator-maintained Codex and host controls, not a built-in Office Claws secret vault or automatic redaction feature. Private networking does not prevent a process from reading credentials already on its host.
Start with one Codex VPS runner, connect an eligible ChatGPT plan, and add credentials only when a specific reviewed task needs them. Office Claws starts at $4.99/month for the first agent, with VPS charges separate. An available 24/7 server does not mean unlimited model usage; our subscription versus API cost guide separates those costs. Our recommendation: keep the coding environment small, verify it with fake data, and keep the power to deploy somewhere else.