T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/setup_token.sh:9
- Finding
- API Token Exposed Through Chat and Command-Line Arguments## Vulnerability Details **File Location**: `scripts/setup_token.sh:9-29`; related workflow instructions at `SKILL.md:134-152` and `scripts/chat.sh:99,116` **Vulnerability Type**: Insecure credential handling **Risk Level**: Medium ### Vulnerable Code `scripts/setup_token.sh:9-29`: ```bash set -euo pipefail TOKEN="${1:-}" # Check HOME directory if [ -z "${HOME:-}" ]; then echo "[ERROR] Unable to determine the user's HOME directory." exit 1 fi TOKEN_FILE="${HOME}/.MIAOWEN_ACCESS_TOKEN" if [ -z "$TOKEN" ]; then echo "[ERROR] Please provide a Token argument" echo "Usage: bash setup_token.sh \"<YOUR_TOKEN>\"" exit 1 fi # Write the Token to the file, replacing any existing value echo -n "$TOKEN" > "$TOKEN_FILE" ``` `SKILL.md:134-152`: ```markdown > 5. Paste the copied Token to me ... > After obtaining the Token, paste it to me, and I will automatically save it to the configuration file. When the user provides a Token, use the `scripts/setup_token.sh` script to save it: ```bash bash scripts/setup_token.sh "<TOKEN_VALUE>" ``` ``` `scripts/chat.sh:99` and `scripts/chat.sh:116`: ```bash echo "After obtaining the Token, paste it to me, and I will automatically save it." ``` ```bash echo "After obtaining the Token, paste it to me, and I will save it again." ``` ### Technical Analysis The documented workflow asks the user to disclose an API credential directly in an AI conversation. The agent is then instructed to place that credential in the first positional argument of `setup_token.sh`. Secrets passed this way may be retained in conversation history, agent execution telemetry, audit logs, or tool-call records. Command-line arguments can also be exposed through process-inspection facilities while the process is running. Depending on the operating system and its process-access restrictions, they may be visible to the same user, admi ...[truncated 1747 chars]
- Remediation
- ## Remediation Suggestions 1. Do not ask users to paste API tokens into an AI conversation. Direct users to configure the credential through a trusted local terminal or dedicated secret-management interface. 2. Remove positional-argument token handling from `setup_token.sh`. Read the secret silently from an interactive terminal, for example with `IFS= read -rs TOKEN`, or accept it through a protected file descriptor or standard input when automation is necessary. 3. Do not include token values in tool-call parameters, command logs, diagnostic output, or error messages. Apply explicit secret redaction to agent and execution telemetry. 4. Create the token file with restrictive permissions from the outset rather than tightening permissions only after writing: ```bash umask 077 TOKEN_FILE="${HOME}/.MIAOWEN_ACCESS_TOKEN" IFS= read -rs -p "Miaowen API token: " TOKEN printf '\n' printf '%s' "$TOKEN" > "$TOKEN_FILE" chmod 600 "$TOKEN_FILE" unset TOKEN ``` 5. Update `SKILL.md` and `chat.sh` so they never direct users to submit credentials through chat or command-line arguments. 6. Advise users who followed the previous workflow to rotate their token and remove any exposed value from conversation records, shell history, and retained execution logs where possible.
