Problem
When running clawdbot security audit, the command detects hardcoded secrets in config but --fix doesn't help migrate them. Users must manually:
- Identify all secret fields
- Create
.env file
- Update config to use
${ENV_VAR} syntax
- Set proper permissions on
.env
This is error-prone and tedious, especially for configs with many tokens (Discord bots, Telegram accounts, API keys).
Proposed Solution
Add a --fix-secrets flag (or include in --fix) that:
-
Scans config for known secret patterns:
*.token, *.botToken, *.apiKey, *.authToken
- Provider-specific fields in
models.providers.*.apiKey
- Skill API keys in
skills.entries.*.apiKey
- Sandbox env vars containing secrets
-
Generates .env file with extracted values:
# Generated by clawdbot security audit --fix-secrets
DISCORD_HERMES_TOKEN=MTQ2NDcw...
TELEGRAM_HERMES_TOKEN=8139723...
ZAI_API_KEY=122c9b68...
-
Updates config to reference env vars:
"token": "${DISCORD_HERMES_TOKEN}"
-
Sets proper permissions (chmod 600 .env)
-
Prints reminder to add .env to .gitignore
Example Output
$ clawdbot security audit --fix-secrets
Found 12 hardcoded secrets:
- channels.discord.accounts.hermes.token
- channels.telegram.accounts.default.botToken
- models.providers.zai.apiKey
...
Created: ~/.clawdbot/.env (chmod 600)
Updated: ~/.clawdbot/clawdbot.json
⚠️ Add .env to your backup exclusions
⚠️ Restart gateway to apply changes
Related
Problem
When running
clawdbot security audit, the command detects hardcoded secrets in config but--fixdoesn't help migrate them. Users must manually:.envfile${ENV_VAR}syntax.envThis is error-prone and tedious, especially for configs with many tokens (Discord bots, Telegram accounts, API keys).
Proposed Solution
Add a
--fix-secretsflag (or include in--fix) that:Scans config for known secret patterns:
*.token,*.botToken,*.apiKey,*.authTokenmodels.providers.*.apiKeyskills.entries.*.apiKeyGenerates
.envfile with extracted values:# Generated by clawdbot security audit --fix-secrets DISCORD_HERMES_TOKEN=MTQ2NDcw... TELEGRAM_HERMES_TOKEN=8139723... ZAI_API_KEY=122c9b68...Updates config to reference env vars:
Sets proper permissions (
chmod 600 .env)Prints reminder to add
.envto.gitignoreExample Output
Related