Skip to content

AP002: Secret in agent settings

Severity critical
Runs in scan, pack, guard hook, git push check
One-line fix Rotate this key, remove it from the settings file, and load it from an environment variable instead.

A key written in an agent’s settings, permission allowlist or config file, such as ~/.claude/settings.json or .claude/settings.local.json. It also finds a key inside an agent file that would ship in a package (see AP006) or sits in a tracked settings file that a git push would send.

Each print shows the line and the key masked, for example sk-p…(len 56).

A key in a settings file is a key in plain text. Project settings files are often committed, and package files are public the moment you publish. A published key has to be treated as stolen.

  1. Rotate the key. Revoke it and create a new one with its provider.
  2. Delete the key from the file and load it from an environment variable instead.
  3. If the file is in a package or in git, remove it there too (see AP006 and AP007).
  • Pattern-based only. An odd key format can be missed.
  • A key inside an MCP server entry is reported as AP005 instead, with a fix that fits MCP.
  • agentprint never uses the key, so it cannot say whether it still works.