Fix: plaintext API keys in config files
Find keys in configs, .env files and memory files. Move them out. Rotate them.
Plain Markdown for agents: /articles/fix-secrets-at-rest.md
Check: secrets at rest. Controls: ASI03, MCP01. A live leaked key is critical.
Detect
List files that hold a key. This prints file names only:
grep -rEl "sk-ant-[A-Za-z0-9_-]{20,}|sk-[A-Za-z0-9]{32,}|AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{36}|sk_live_[A-Za-z0-9]{20,}" \
~/.config ~/.claude ~/.codex ~/.cursor ~/.openclaw ~/.env ./ \
--include='*.json' --include='*.env' --include='.env*' --include='*.md' --include='*.yaml' --include='*.yml' --include='*.toml' \
2>/dev/null | head -50
Check shell history too:
grep -cE "sk-ant-|AKIA|ghp_" ~/.zsh_history ~/.bash_history 2>/dev/null
Never paste a found key into chat, a ticket or an upload. The Checkup uploads a sha256 fingerprint and a redacted path, not the value.
Fix
sma fix --vault
This moves plaintext secrets into Agent Secret Store and rewrites configs to use scoped tokens.
Without the vault:
- Put the key in the OS keychain or an env var set at launch.
- Replace the file value with a reference such as
${OPENAI_API_KEY}. - Add
.env*to.gitignore. Check history:git log -p -S'sk-ant-' | head. - Lock file modes:
chmod 600 ~/.env.
Rotate
Every key that sat in plaintext counts as exposed. Create a new one at the provider, update the reference, then revoke the old one.
Background: The Moltbook token leak.