T09 · Insecure Skill Coding Practices
Warning
- Location
- skill.md:61
- Finding
- Insecure Plaintext API Key Storage Guidance in Skill Documentation<![CDATA[ ## Vulnerability Details **File Location**: `skill.md`, lines 61–72 **Vulnerability Type**: Plaintext credential storage and unsafe secret-retention guidance **Risk Level**: Medium ### Vulnerable Code ```markdown **⚠️ Save your `api_key` immediately!** You need it for all requests. **Recommended:** Save your credentials to `~/.config/dungeons-and-lobsters/credentials.json`: ```json { "api_key": "dal_xxx...", "bot_name": "YourBotName" } ``` This way you can always find your key later. You can also save it to your memory, environment variables (`DNL_API_KEY`), or wherever you store secrets. ``` ### Technical Analysis The Skill recommends storing a bearer API key in a plaintext JSON file but does not require restrictive directory and file permissions. The resulting permissions depend on the Agent's umask and file-creation method, which may leave the credential readable by other local users or processes. The alternative recommendation to retain the key in Agent memory is also unsafe. Persistent memory may be included in future model contexts, diagnostics, backups, exports, or unrelated tool workflows. Storing a secret there unnecessarily expands the number of components and sessions that may receive it. An API credential is necessary for the declared game functionality, so obtaining and using the Skill's own token does not exceed minimum privilege. However, retaining it in unspecified plaintext storage or Agent memory is not necessary. The audit found no code that searches unrelated credential paths, reads existing secrets, or sends the key to an unrelated domain. ### Attack Path 1. A user or Agent follows the documented recommendation and writes the API key to `~/.config/dungeons-and-lobsters/credentials.json` without explicitly setting secure permissions, or stores it in persistent Agent memory. 2. A local process, another user, a diagnostic collector, a backup system, or a later Agent workflow gains access to the file or memory context. 3 ...[truncated 800 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Prefer an operating-system credential manager or a platform-provided secret store instead of a plaintext file. 2. If file-based storage is required: - Create `~/.config/dungeons-and-lobsters` with mode `0700`. - Create `credentials.json` with mode `0600`. - Write the file atomically while preserving restrictive permissions. - Refuse to use the file, or emit a prominent warning, when group or world access is detected. 3. Remove the recommendation to store API keys in Agent memory. Store only non-sensitive identifiers such as room IDs and timestamps there. 4. Describe environment-variable exposure risks, including inheritance by child processes and possible disclosure through diagnostics or process inspection. 5. Document API-key revocation and rotation procedures. 6. Ensure logs, recaps, errors, and tool output redact values matching the `dal_` credential format. 7. Replace “wherever you store secrets” with explicit, reviewed storage options and concrete security requirements. ]]>
