T09 · Insecure Skill Coding Practices
Error
- Location
- assets/run-discord.sh:3
- Finding
- Hardcoded Discord, Telegram, and Master API Credentials<![CDATA[ ## Vulnerability Details **File Location**: `assets/run-discord.sh:3-4`, `assets/run-telegram-bot.sh:2-3`, `assets/run-tg.sh:3-4`, `assets/discord-bot.py:29-30`, `assets/telegram-bot.py:30-31` **Vulnerability Type**: Hardcoded authentication credentials **Risk Level**: Critical ### Vulnerable Code ```bash # assets/run-discord.sh export DISCORD_BOT_TOKEN="MTQ5MTcyMzg5NjA5MTcwOTQ4MA.GsDWKB.41EEu1ILpYUd1HNEfTrL1sN_Z2saG8fBls4lxk" export MASTER_API_KEY="ak_2f81a7774dc7445a9244d3f61d5a9a989c25dbfef09dfb4c868c372260722f93" ``` ```bash # assets/run-telegram-bot.sh and assets/run-tg.sh export TELEGRAM_BOT_TOKEN="8697590926:AAHH6uQ2Zioj3kUFNd23B5C5q0L6wUIt7f4" export MASTER_API_KEY="ak_2f81a7774dc7445a9244d3f61d5a9a989c25dbfef09dfb4c868c372260722f93" ``` ```python # assets/discord-bot.py API_BASE = "https://api.cowork.digen.ai" MASTER_API_KEY = os.getenv( "MASTER_API_KEY", "ak_2f81a7774dc7445a9244d3f61d5a9a989c25dbfef09dfb4c868c372260722f93" ) ``` ```python # assets/telegram-bot.py API_BASE = "https://api.cowork.digen.ai" MASTER_API_KEY = os.getenv( "MASTER_API_KEY", "ak_2f81a7774dc7445a9244d3f61d5a9a989c25dbfef09dfb4c868c372260722f93" ) ``` ### Technical Analysis The package contains usable-looking Discord and Telegram bot tokens and a privileged master API key. The master key remains exposed even when the launch scripts are not used because both bot implementations define it as the default value when `MASTER_API_KEY` is absent. These secrets are available to every person or automated system that can download or inspect the Skill. Environment-variable support does not mitigate the issue when a working secret is also embedded as a fallback. The bots use the master key as a Bearer credential for: ```python r = requests.post( f"{API_BASE}/b/v1/api-key/create", headers={"Authorization": f"Bearer {MASTER_API_KEY}"}, timeout=30 ) ``` Consequently, compromise of the master key may grant the ability to create additional user API ...[truncated 954 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Immediately revoke and rotate the exposed Discord token, Telegram token, and master API key. 2. Review provider-side access and issuance logs for use of the exposed credentials. 3. Remove all credentials from the current files and repository history. 4. Remove hardcoded fallback values: ```python MASTER_API_KEY = os.getenv("MASTER_API_KEY") if not MASTER_API_KEY: raise RuntimeError("MASTER_API_KEY is required") ``` 5. Obtain production secrets from a dedicated secret manager or protected runtime environment. 6. Ensure launch scripts reference environment variables without assigning secret values. 7. Add secret scanning to development and release pipelines. 8. Restrict the master key to only the key-creation permission, impose issuance quotas, and support rapid revocation. ]]>
