T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/setup.sh:55
- Finding
- API keys are entered visibly and persisted as plaintext shell configuration<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.sh`, lines 55-64 and 84-89 **Vulnerability Type**: Plaintext credential storage and visible secret input **Risk Level**: High ### Vulnerable Code ```bash read -rp " 请输入 DashScope API Key(留空则使用 sub-agent / 主 agent 默认配置): " INPUT_DASHSCOPE if [ -n "$INPUT_DASHSCOPE" ]; then export DASHSCOPE_API_KEY="$INPUT_DASHSCOPE" if [ -n "$SHELL_RC" ]; then if ! grep -q "DASHSCOPE_API_KEY" "$SHELL_RC"; then echo "" >> "$SHELL_RC" echo "# Finance Daily Report — DashScope API Key" >> "$SHELL_RC" echo "export DASHSCOPE_API_KEY=\"$INPUT_DASHSCOPE\"" >> "$SHELL_RC" echo -e "${GREEN}✓ 已写入 $SHELL_RC${NC}" fi fi fi ``` ```bash read -rp " 可选:输入豆包 API Key 作为备用模型(留空跳过): " INPUT_DOUBAO if [ -n "$INPUT_DOUBAO" ]; then export DOUBAO_API_KEY="$INPUT_DOUBAO" if [ -n "$SHELL_RC" ] && ! grep -q "DOUBAO_API_KEY" "$SHELL_RC"; then echo "export DOUBAO_API_KEY=\"$INPUT_DOUBAO\"" >> "$SHELL_RC" echo -e "${GREEN}✓ DOUBAO_API_KEY 已写入 $SHELL_RC${NC}" fi fi ``` ### Technical Analysis The setup script uses `read -rp`, which does not suppress terminal echo. API keys are therefore displayed while the user types them and may be exposed to screen recording, terminal sharing, shoulder surfing, or terminal logging. The keys are subsequently written verbatim into `.bashrc` or `.zshrc`. These files are ordinary plaintext files and may be exposed through backups, diagnostic bundles, accidental repository commits, overly permissive home-directory permissions, or unrelated processes running under the same account. The script does not verify or harden the shell configuration file's permissions. It also writes user-controlled data into shell syntax without validating the expected API-key character set. A value containing shell substitution syntax such as `$(...)` would be stored literally and evaluated the next time the shell configurat ...[truncated 2010 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Use hidden terminal input: ```bash read -rsp "Enter DashScope API key: " INPUT_DASHSCOPE printf '\n' ``` 2. Do not write credentials to `.bashrc` or `.zshrc`. Use the operating system's credential manager, OpenClaw's secret store, or a dedicated file readable only by the owner. 3. If a dedicated secret file is unavoidable: - Create it with `umask 077`. - Set mode `0600`. - Store it outside repositories and workspace directories. - Document deletion and rotation procedures. 4. Validate keys against the provider's expected character set and maximum length before storage. 5. Never generate executable shell source from untrusted credential input. If shell environment integration is required, safely quote the value using a robust shell-escaping mechanism rather than string interpolation. 6. Add a warning explaining which providers receive data and how credentials will be stored. 7. Rotate any API keys previously stored by the existing setup script and remove them from shell history, startup files, backups, and diagnostic archives where practical. ]]>
