T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/clawclash.sh:105
- Finding
- API Credential Disclosed in Terminal and Agent Output<![CDATA[ ## Vulnerability Details **File Location**: `scripts/clawclash.sh`, lines 105 and 305 **Vulnerability Type**: Sensitive credential exposure through command output **Risk Level**: Medium ### Vulnerable Code Registration output at line 105: ```bash echo -e " Key: ${YELLOW}$api_key${NC}" ``` The `whoami` command at lines 297–307 also exposes the credential: ```bash cmd_whoami() { if [[ ! -f "$CONFIG_FILE" ]]; then echo -e "${RED}Not registered.${NC}" exit 1 fi if command -v jq &>/dev/null; then echo -e "${CYAN}Current Agent${NC}" jq -r '" Name: \(.name)\n ID: \(.id)\n API Key: \(.api_key)"' "$CONFIG_FILE" else cat "$CONFIG_FILE" fi } ``` ### Technical Analysis The script treats the API key as a bearer credential: ```bash -H "Authorization: Bearer $api_key" ``` However, the complete key is printed immediately after registration and whenever `whoami` is invoked. If `jq` is unavailable, `whoami` prints the entire configuration file, which also contains the API key. Secrets written to standard output can be retained in agent transcripts, CI logs, terminal capture systems, screen-sharing sessions, support bundles, or other command-output collection mechanisms. File mode `600` on the configuration file does not protect the credential once it has been copied into output. ### Attack Path 1. A user or agent invokes `register` or `whoami`. 2. The script prints the complete API key to standard output. 3. The output is retained in an agent transcript, CI log, terminal recording, or shared screen. 4. An unauthorized party obtains the exposed key. 5. The party supplies it as an `Authorization: Bearer` credential to the ClawClash API. 6. API operations are performed under the victim agent's identity. ### Impact Assessment An attacker who obtains the key can impersonate the registered ClawClash agent within the privileges granted by the remote service. This may permit starting attempts, taking interactive turns, submitti ...[truncated 211 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove all output of the complete API key from `register` and `whoami`. - Restrict `whoami` to non-sensitive fields such as agent name and ID. - If identification of the active key is necessary, display only a short redacted fingerprint, such as `abcd…wxyz`. - Ensure the no-`jq` fallback does not use `cat "$CONFIG_FILE"`; parse and display only approved non-secret fields. - Consider printing a one-time warning that the credential was stored securely without displaying its value. - Review historical agent transcripts and CI logs for previously exposed credentials and rotate any affected API keys. ]]>
