T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/setup-auto-drive.sh:43
- Finding
- API key is entered with terminal echo enabled<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup-auto-drive.sh:43-48` **Vulnerability Type**: Credential exposure through visible terminal input **Risk Level**: Medium ### Vulnerable Code ```bash read -rp "Paste your API key here: " API_KEY API_KEY="${API_KEY//[[:space:]]/}" if [[ -z "$API_KEY" ]]; then echo -e "${RED}Error: No API key provided.${NC}" >&2 exit 1 fi ``` ### Technical Analysis Bash's `read` command displays entered characters unless the `-s` option is used. Consequently, the Auto-Drive API key remains visible on the terminal while the user enters or pastes it. The key can therefore be exposed through shoulder surfing, screen sharing, terminal session recording, screenshots, remote support software, or other processes that capture terminal output. Removing whitespace after input does not protect the credential from this disclosure. ### Attack Path 1. A user runs `scripts/setup-auto-drive.sh`. 2. The script prompts the user to paste an Auto-Drive API key. 3. Because `read -r` is used without `-s`, the complete key appears on the terminal. 4. An observer, screen-recording system, shared terminal session, or remote support participant captures the displayed key. 5. The attacker uses the captured bearer credential against the Auto-Drive API. ### Impact Assessment An attacker who obtains the API key can act within the authorization scope granted to that key. Based on the audited functionality, this may include consuming upload credits, uploading attacker-controlled content under the victim's account, and accessing authenticated Auto-Drive account or object operations. This does not directly grant local operating-system privileges, but it compromises the associated Auto-Drive account and may create financial, quota, privacy, or integrity consequences. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions Use silent terminal input and print a newline after the prompt: ```bash read -rsp "Paste your API key here: " API_KEY printf '\n' ``` Additional hardening measures: 1. Ensure the key is never printed in success, failure, or debugging output. 2. Disable shell tracing around credential-handling code if callers could enable `set -x`. 3. Prefer an operating-system credential store or secret manager where available. 4. Document immediate key rotation if the key is exposed during setup. ]]>
