| name | security-audit |
| description | Security checklist specific to claude-code-discord-bridge — subprocess injection, env leaks, input validation |
Security Audit — claude-code-discord-bridge Specific
This project runs arbitrary Claude Code sessions triggered by Discord messages. Security is the #1 priority.
When to Activate
- Before any commit that changes
runner.py, _run_helper.py, or any Cog
- When adding new user-facing commands
- When modifying subprocess execution or argument passing
- When adding new environment variables or configuration
- Periodically as a full audit
Threat Model
| Threat | Vector | Mitigation |
|---|
| Command injection | User message passed to CLI args | create_subprocess_exec (no shell), -- separator |
| Flag injection | Prompt starting with - | -- separator before prompt |
| Session hijack | Fake session ID | Strict regex validation ^[a-f0-9\-]+$ |
| Skill injection | Malicious skill name | Strict regex validation ^[\w-]+$ |
| Secret exfiltration | Claude Bash tool reads env | Strip secrets from subprocess env |
| Nesting attack | Claude spawns another claude-code-discord-bridge | Strip CLAUDECODE from env |
| Token theft | Bot token in logs/errors | Never log tokens, strip from env |
Checklist
Subprocess Safety
Environment Security
Input Validation
Error Handling
Dependencies
Quick Scan Commands
grep -rn "shell=True" claude_discord/
grep -rn "subprocess\.call" claude_discord/
grep -rn "subprocess\.run" claude_discord/
grep -n "_STRIPPED_ENV_KEYS" claude_discord/claude/runner.py
grep "\.env" .gitignore
Response Protocol
- CRITICAL (injection, secret leak): Stop immediately. Fix before any other work.
- HIGH (missing validation): Fix before committing.
- MEDIUM (logging concern): Fix in the same PR.
- LOW (style/hardening): Track as a follow-up issue.