T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:274
- Finding
- Insecure Collection and Broad Plaintext Storage of Access Tokens<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:274-285`; `cnb-pull.sh:31-60` **Vulnerability Type**: Plaintext secret collection, shared credential storage, and unnecessarily broad environment-variable exposure **Risk Level**: High ### Vulnerable Code `SKILL.md:274-285`: ```markdown ### Step 3 — Provide Parameters to openclaw Reply with these 4 values: | Parameter | Description | Example | |-----------|-------------|---------| | `CNB_TOKEN` | CNB access token | `8B76Bopie1d966fVDMgJnhFRepZ` | | `CNB_REGISTRY` | CNB registry address (fixed value) | `docker.cnb.cool` | | `CNB_REPO_SLUG` | CNB namespace (lowercase) | `lufei123/lufei-docker` | | `CNB_GITHUB_REPO` | Private repo address (format: `your-github-username/cnb-docker-sync`) | `your-github-username/cnb-docker-sync` | **openclaw will automatically:** 1. Write to `~/.openclaw/.env` (please keep this file trusted — run `chmod 600 ~/.openclaw/.env`) ``` `cnb-pull.sh:31-60`: ```bash local env_file="$HOME/.openclaw/.env" if [[ ! -f "$env_file" ]]; then return 0 fi while IFS= read -r line || [[ -n "$line" ]]; do [[ "$line" =~ ^# ]] && continue [[ -z "${line// }" ]] && continue if [[ "$line" =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then local key="${line%%=*}" case "$key" in CNB_TOKEN|CNB_REGISTRY|CNB_REPO_SLUG|CNB_GITHUB_REPO|GITHUB_TOKEN) local val="${line#*=}" val="${val//\"/}" val="${val//\'/}" val="${val#"${val%%[![:space:]]*}"}" val="${val%"${val##*[![:space:]]}"}" export "$key"="$val" ;; esac fi done < "$env_file" ``` ### Technical Analysis The Skill explicitly instructs users to submit `CNB_TOKEN` through the Agent conversation and states that the credential will be written to the shared `~/.openclaw/.env` file. This creates multiple unnec ...[truncated 2336 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not ask users to submit access tokens through chat or Agent messages. 2. Collect secrets directly in a trusted terminal using hidden input, such as `read -rs`, or through the provider's authenticated device flow. 3. Prefer `gh auth login` and GitHub CLI credential management instead of requiring `GITHUB_TOKEN` in the OpenClaw environment file. 4. Store the CNB token in an operating-system keychain or a dedicated Skill-specific secret store. 5. If file storage is unavoidable: - Create a dedicated file with `umask 077`. - Enforce mode `0600`. - Verify that the current user owns the file. - Reject symlinks and files with group or world permissions. 6. Do not export credentials globally. Supply each credential only to the exact command that needs it, preferably through standard input. 7. Document the exact minimum CNB permissions required and require a short-lived, registry-restricted token. 8. Advise users who previously followed the instructions to rotate any token submitted through chat. ]]>
