T09 · Insecure Skill Coding Practices
Warning
- Location
- memory-template.md:27
- Finding
- Telegram Bot Token Persisted in Plaintext Configuration Files<![CDATA[ ## Vulnerability Details **File Location**: `memory-template.md:27-38`; supporting instructions in `setup.md:18-21` and `setup.md:42-52` **Vulnerability Type**: Plaintext credential storage **Risk Level**: Medium ### Vulnerable Code ```markdown ## Bot Configuration Create `~/telegram-bot-api/bots/{botname}.md`: ```markdown # Bot: {Bot Name} ## Config username: @{username} token: {BOT_TOKEN} created: YYYY-MM-DD ``` ``` The corresponding setup instructions explicitly direct the agent to persist the credential: ```markdown **If they share a token:** 1. Ask permission: "Want me to save this token locally so I can help you test?" 2. If yes, save to `~/telegram-bot-api/bots/{botname}.md` 3. Confirm: "Saved to ~/telegram-bot-api/bots/{name}.md — I won't display it again" ``` ### Technical Analysis A Telegram bot token is a bearer credential. Anyone who obtains it can invoke the Telegram Bot API with the bot's identity and permissions. The Skill instructs the agent to place this credential directly into an ordinary Markdown file. It does not require restrictive file permissions, an encrypted credential store, an operating-system keychain, protection from backup or synchronization systems, or exclusion from source control. Obtaining user consent to save the token does not address the security properties of the storage mechanism. The declaration that the token remains local also does not protect it from other local accounts, malware, indexing services, backup software, accidental repository commits, or other applications operating under the same user account. ### Attack Path 1. The user supplies a valid Telegram bot token and permits the Skill to save it. 2. The Skill creates `~/telegram-bot-api/bots/{botname}.md` containing the plaintext token. 3. The file is exposed through permissive filesystem permissions, a backup, synchronization, indexing, accidental source-control commit, or compromise of the local account. 4. An attacker extracts the token ...[truncated 732 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Store bot tokens in an operating-system keychain or dedicated secret manager rather than Markdown configuration. 2. Keep only a secret reference or environment-variable name in the bot configuration. 3. If file storage is unavoidable: - Create `~/telegram-bot-api/` with mode `0700`. - Create credential files with mode `0600`. - Separate secrets from ordinary preferences and templates. - Avoid placing tokens in files likely to be indexed, synchronized, or committed. 4. Add source-control ignore rules and secret-scanning guidance. 5. Clearly document backup and synchronization risks before saving a token. 6. Provide token rotation instructions using BotFather and require rotation after suspected exposure. 7. Avoid copying the token into generated examples, command history, diagnostic output, or exception messages. ]]>
