T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:34
- Finding
- Bearer Token Stored in a Predictable Plaintext File Without Explicit Permission Hardening<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 34–37 **Vulnerability Type**: Plaintext sensitive credential storage **Risk Level**: Medium ### Vulnerable Code ```bash # Save for later mkdir -p ~/.openclaw/workspace/skills/diarybeast echo "$TOKEN" > ~/.openclaw/workspace/skills/diarybeast/.token echo "$ADDRESS" > ~/.openclaw/workspace/skills/diarybeast/.address ``` ### Technical Analysis The skill instructs the agent to persist an authentication bearer token in a predictable plaintext file. It does not set restrictive permissions on either the directory or the token file, verify ownership, or remove the credential after expiration. The resulting access permissions depend on the user's current `umask` and the security of the surrounding workspace. If the file is readable by another local user, process, agent, plugin, backup service, or workspace integration, that party can recover the bearer token without possessing the wallet's private key. The documented session lasts 24 hours, so a stolen token may remain useful for the remainder of that period. ### Attack Path 1. A user authenticates to DiaryBeast by signing the requested wallet authentication message. 2. The remote service returns a bearer token. 3. The documented commands write that token to `~/.openclaw/workspace/skills/diarybeast/.token`. 4. Because no explicit restrictive permissions are applied, a local process or user with access to the workspace reads the predictable file. 5. The attacker submits the stolen token in an `Authorization: Bearer` header. 6. The attacker can invoke DiaryBeast endpoints available to the authenticated account until the token expires or is revoked. ### Impact Assessment Successful exploitation allows impersonation of the authenticated DiaryBeast account within the privileges granted to the bearer token. Based on the documented API operations, this may include reading account or pet state, creating diary entries, publishing content, modifyin ...[truncated 391 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Avoid persisting the bearer token unless persistence is required. - Prefer an operating-system credential store or another secret-management facility rather than a workspace file. - If file storage is unavoidable, create the directory and file with explicit restrictive permissions: ```bash install -d -m 700 ~/.openclaw/workspace/skills/diarybeast umask 077 printf '%s\n' "$TOKEN" > ~/.openclaw/workspace/skills/diarybeast/.token chmod 600 ~/.openclaw/workspace/skills/diarybeast/.token ``` - Verify that the directory and file are owned by the expected user and reject symbolic links before writing. - Never print the token to logs or include it in diagnostic output. - Delete the token when the session expires or the user logs out. - Support explicit server-side token revocation and use short-lived, least-privilege tokens where possible. ]]>
