T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:33
- Finding
- OAuth Tokens Stored in a Plaintext Workspace File## Vulnerability Details **File Location**: `SKILL.md`, lines 33–44 **Vulnerability Type**: Plaintext storage of sensitive OAuth credentials **Risk Level**: Medium ### Vulnerable Code Snippet The following is an English translation of the relevant source documentation: ```markdown ### 2. Token Management - The access token is valid for approximately two hours. - The refresh token is valid for approximately 30 days. - Use the refresh token after expiration. Tokens are stored in `~/.openclaw/workspace/feishu_tokens.md`. ## Usage ```bash USER_TOKEN="xxx" # Read from feishu_tokens.md ``` ``` The token is subsequently used as a bearer credential in the Feishu API request at lines 68–70: ```bash curl -s -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars/${CALENDAR_ID}/events" \ -H "Authorization: Bearer $USER_TOKEN" \ -H "Content-Type: application/json" ``` ### Technical Analysis The Skill explicitly directs the user or Agent to persist OAuth access and refresh tokens in a Markdown file under the OpenClaw workspace. It does not require restrictive file permissions, encryption, an operating-system credential store, a platform secret manager, token redaction, or secure deletion. OAuth bearer tokens grant access based on possession. A process that obtains the token does not need the user's password to exercise the permissions associated with it. The refresh token presents greater exposure because the documentation states that it remains valid for approximately 30 days and can be used to obtain replacement access tokens. Keeping credentials inside a workspace also increases the chance of unintended disclosure through workspace synchronization, backups, diagnostic archives, source-control operations, broad local permissions, or access by another local process. ### Attack Path 1. The Skill stores an access token and potentially a refresh token in `~/.openclaw/workspace/feishu_tokens.md` ...[truncated 1403 chars]
- Remediation
- ## Remediation Suggestions 1. Store access and refresh tokens in the OpenClaw credential store, an operating-system keychain, or a dedicated secret-management service rather than a Markdown workspace file. 2. If file-based storage is unavoidable, place the file outside synchronized or project workspaces and enforce owner-only permissions such as mode `0600`. 3. Encrypt credentials at rest using a key that is not stored alongside the encrypted token data. 4. Avoid printing, logging, embedding, or returning bearer tokens in command output, diagnostics, or Agent responses. 5. Request only the minimum Feishu OAuth scopes needed for the requested operation. 6. Implement secure token refresh handling, including refresh-token rotation where supported and deletion of superseded credentials. 7. Revoke and rotate any tokens that may already have been stored in broadly accessible workspace files. 8. Document explicit cleanup procedures so credentials are removed when authorization is revoked or the Skill is uninstalled.
