T09 ยท Insecure Skill Coding Practices
- Location
- SKILL.md:22
- Finding
- Bearer API Key Stored Without Restrictive File Permissions## Vulnerability Details **File Location**: `SKILL.md`, lines 22โ26 **Vulnerability Type**: Plaintext credential storage with insecure default permissions **Risk Level**: Medium ### Vulnerable Code ```bash mkdir -p ~/.kradle/kradleverse cat > ~/.kradle/kradleverse/.env << 'EOF' KRADLEVERSE_AGENT_NAME=<your_agent_name> KRADLEVERSE_API_KEY=<your_api_key> EOF ``` ### Technical Analysis The Skill recommends storing a reusable Kradleverse bearer API key in a plaintext `.env` file but does not set restrictive permissions on either the containing directory or the credential file. On systems using a common `022` umask, `mkdir` may create the directory with mode `0755`, while shell redirection may create the file with mode `0644`. In a multi-user environment, this can allow other local users to read the API key. Because the documented API uses the value directly as an `Authorization: Bearer` credential, possession of the key is sufficient for agent impersonation. Access to a dedicated Kradleverse credential is functionally necessary for authenticated game operations and does not inherently exceed least privilege. The vulnerability is the insecure storage recommendation rather than the act of generating or using the credential. ### Attack Path 1. A user follows the initialization commands in `SKILL.md`. 2. The directory and `.env` file are created with permissions derived from the user's current umask. 3. Under permissive defaults, another local account reads `~/.kradle/kradleverse/.env`. 4. The attacker extracts `KRADLEVERSE_API_KEY`. 5. The attacker supplies the stolen value as an HTTP bearer token to the documented Kradleverse endpoints. 6. The attacker impersonates the registered agent until the credential is revoked or rotated. ### Impact Assessment A successful attacker could exercise the Kradleverse privileges associated with the stolen key, including: - Joining or interacting with matchmaking queues. - Reading active game observations where the API per ...[truncated 409 chars]
- Remediation
- ## Remediation Suggestions Create the credential directory and file with owner-only permissions: ```bash install -d -m 700 ~/.kradle/kradleverse umask 077 cat > ~/.kradle/kradleverse/.env << 'EOF' KRADLEVERSE_AGENT_NAME=<your_agent_name> KRADLEVERSE_API_KEY=<your_api_key> EOF chmod 600 ~/.kradle/kradleverse/.env ``` Additional hardening measures: 1. Prefer an operating-system credential store or secret manager instead of a plaintext `.env` file where supported. 2. Never print the API key in logs, progress messages, chat, post-game interviews, or the optional `thoughts` field. 3. Document credential revocation and rotation procedures. 4. Validate file ownership and permissions before reading an existing credential file. 5. Refuse to use credential files owned by another user or writable by group/other accounts. 6. Standardize the documented path. The file alternates between `~/.kradle/kradleverse/.env` and `~/.kradleverse/.env`, which may create duplicate or orphaned credential files. 7. Minimize optional registration data such as `identity`, `humanInstructions`, and `soul`, and obtain informed user approval before transmitting potentially private information.
