Skip to content

Agent logins and keys

Protects against an agent reading or overwriting the login, provider keys and OAuth tokens that Claude Code, Codex, GitHub Copilot CLI, pi, Gemini CLI, OpenCode, Hermes Agent, OpenClaw, the Cline CLI, goose and the Continue CLI keep on your machine, its own included, and then sending them out.

The default rule agent-credentials denies the agent’s own tools reading or writing those files: a shell command naming them, a file tool, an MCP argument. Examples are OpenCode’s ~/.local/share/opencode/auth.json, Hermes Agent’s auth.json and mcp-tokens/, Codex’s auth.json, the Cline CLI’s stored provider keys (~/.cline/data/settings/providers.json) and connector credentials, and goose’s secrets.yaml (where goose keeps provider keys when its keyring is off). It also covers an agent directory you moved to another place.

Commands that print a stored agent token are covered too: pi auth print-api-key, pi auth print-bearer-token, opencode auth export and secret-tool lookup are denied, and claude setup-token needs review (agent-token).

Command Verdict Rule
cat ~/.codex/auth.json, cat ~/.local/share/opencode/auth.json deny agent-credentials
claude setup-token review agent-token

Inside the sandboxes too (from 0.16.0). Every OS sandbox now denies these files to the commands an agent runs, so a test, a package script or a downloaded binary cannot read another agent’s token, nor the agent’s own under Claude Code’s, Codex’s and Cursor’s sandboxes, which confine only those commands. The agents still sign in. openmoat run holds the agent itself, so it keeps the login of the agent it starts readable (run.own-login) and denies the others’.

Terminal window
openmoat sandbox show # lists both: what each sandbox denies, and run.own-login
Terminal window
openmoat policy check "cat ~/.codex/auth.json"

The first line of the output is ✕ deny, and the rule is agent-credentials.

Copying the whole folder that holds such a file is one read of the folder, not of the file. That needs review, with rule protected-contents: see Folders that hold denied files.

Command What it does Example
openmoat policy upgrade Takes the agent-credentials rule into a policy written before 0.11.0, and the sandbox denies into one written before 0.16.0 openmoat policy upgrade
openmoat sandbox show What each sandbox denies, run.own-login included openmoat sandbox show
openmoat policy check "<command>" Shows the verdict and rule; nothing runs openmoat policy check "cat ~/.local/share/opencode/auth.json"
openmoat edit The only way to change a deny rule openmoat edit
  • Under openmoat run, the agent’s own login is readable to the commands it runs. openmoat run holds the agent itself, so it keeps that agent’s login readable, and code inside an allowed command can read it there; other agents’ logins stay denied. An API-key login can go through the broker instead (BROKER_LOGINS.md); an OAuth login cannot (ADR-054).
  • Without an OS sandbox, the hook is the only check. On a hook-only agent, a program an allowed command runs (a test, a package script, a downloaded binary) can read them. hook_only: true on the group restores the hook-only behaviour of 0.15.0 and earlier everywhere. Where no OS sandbox holds the command, a script the session wrote needs review before it runs (Code the agent wrote).
  • A folder copy, once approved, holds the files. cp -r ~/.codex x needs review; if you approve it, the copy contains the login.

The full list: Limits and THREAT_MODEL.md §5.