T09 · Insecure Skill Coding Practices
- Location
scripts/discord-server-admin.sh:202- Finding
Discord Bot Token Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/discord-server-admin.sh, lines 9 and 202–204
Vulnerability Type: Insecure credential handling through command-line arguments
Risk Level: MediumVulnerable Code
bash # Line 9 discord-server-admin.sh [--token TOKEN] <command> [args]bash # Lines 202–204 --token) BOT_TOKEN="$2" shift 2Technical Analysis
The script advertises and implements a
--token TOKENoption for supplying the Discord bot credential. Secrets passed as command-line arguments may be recorded in shell history and exposed through process-inspection facilities while the command is running.Although
SKILL.mdrecommends theDISCORD_BOT_TOKENenvironment variable, the executable still provides the less secure command-line option. The token is subsequently used as a Discord Bot authorization credential, so its disclosure grants access equivalent to the permissions assigned to that bot.Attack Path
- An administrator invokes the script using
--tokenfollowed by a valid Discord bot token. - The complete command may be stored in shell history or temporarily exposed in the process argument list.
- A local attacker with access to that history or permission to inspect the process arguments obtains the token.
- The attacker submits authenticated requests to the Discord API as the compromised bot.
- The attacker performs operations allowed by the bot's Discord permissions and role hierarchy.
This path requires local access sufficient to inspect command history or process metadata.
Impact Assessment
Token compromise allows an attacker to impersonate the bot and exercise all privileges granted to it. Within this tool's intended scope, that can include listing, creating, editing, moving, or deleting accessible channels and roles, as well as assigning or removing roles from members. If the bot has broader permissions than required, the stol ...[truncated 315 chars]
- An administrator invokes the script using
- Remediation
View remediation
Remediation Suggestions
- Remove the
--tokenoption from the usage text and argument parser. - Accept the credential only through
DISCORD_BOT_TOKENor an operating-system-backed secret manager. - If interactive credential entry is necessary, read it silently from a TTY so it is not included in process arguments or shell history.
- Document that users must not place tokens directly in command lines, scripts, logs, or checked-in configuration files.
- Grant the Discord bot only the minimum permissions required for the intended channel and role operations.
- Rotate any token that has previously been supplied through
--tokenif command history or process information may have been accessible. - Ensure logs and error handling never print the authorization header or token value.
- Remove the
