T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:36
- Finding
- API Credential Exposed Through Terminal Output, Plaintext Persistence, and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:36-43`, `SKILL.md:50-82`, and `SKILL.md:118-132` **Vulnerability Type**: Insecure credential handling and plaintext sensitive-data exposure **Risk Level**: High ### Vulnerable Code Credential presence is checked by printing its value: ```bash echo $INFOXMED_VIP_PASSWORD ``` ```powershell echo $env:INFOXMED_VIP_PASSWORD ``` The user is instructed to provide the password through the conversation, after which it is persisted in plaintext: ```bash # Detect shell profile if [ -n "$ZSH_VERSION" ] || [[ "$SHELL" == */zsh ]]; then PROFILE="$HOME/.zshrc" elif [ -n "$BASH_VERSION" ] || [[ "$SHELL" == */bash ]]; then PROFILE="$HOME/.bashrc" elif [[ "$SHELL" == */fish ]]; then PROFILE="$HOME/.config/fish/config.fish" else PROFILE="$HOME/.profile" fi # Write to profile (fish uses different syntax) if [[ "$SHELL" == */fish ]]; then echo 'set -gx INFOXMED_VIP_PASSWORD "USER_PROVIDED_PASSWORD"' >> "$PROFILE" else echo '' >> "$PROFILE" echo '# Infoxmed VIP QR API password' >> "$PROFILE" echo 'export INFOXMED_VIP_PASSWORD="USER_PROVIDED_PASSWORD"' >> "$PROFILE" fi # Set for current session export INFOXMED_VIP_PASSWORD="USER_PROVIDED_PASSWORD" ``` ```powershell # Set permanently for current user (persists across reboots) [System.Environment]::SetEnvironmentVariable("INFOXMED_VIP_PASSWORD", "USER_PROVIDED_PASSWORD", "User") # Set for current session $env:INFOXMED_VIP_PASSWORD = "USER_PROVIDED_PASSWORD" ``` The credential is then included directly in the request URL: ```bash curl -s -o /tmp/vip_qr_{timestamp}.zip \ "https://api.infox-med.com/system/batchGenerateVipQr?password=${INFOXMED_VIP_PASSWORD}&agent={url_encoded_agent}&count=1&cardName={url_encoded_cardName}&vipCarType={vipCarType}×={times}" \ -H "Origin: https://admin.infox-med.com" \ -H "Referer: https://admin.infox-med.com/" ``` ```powershell Invoke-WebRequest -Uri "https://api.infox-med.com/system/batchGenerateVipQr?pa ...[truncated 3190 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Check only whether the variable exists.** Do not print its value: ```bash if [ -z "${INFOXMED_VIP_PASSWORD:-}" ]; then echo "INFOXMED_VIP_PASSWORD is not configured." exit 1 fi ``` ```powershell if ([string]::IsNullOrWhiteSpace($env:INFOXMED_VIP_PASSWORD)) { throw "INFOXMED_VIP_PASSWORD is not configured." } ``` 2. **Do not request secrets through ordinary chat.** Direct users to configure the credential outside the agent conversation, or use a platform-provided secret-input mechanism that prevents the value from entering transcripts and tool logs. 3. **Use secure credential storage.** Prefer an operating-system credential manager, a dedicated secret manager, or a permission-restricted credential file. Do not automatically append plaintext secrets to `.bashrc`, `.zshrc`, `.profile`, or Fish configuration files. 4. **Remove credentials from query strings.** Update the API to accept authentication in an authorization header, for example: ```bash curl --fail --silent --show-error \ -H "Authorization: Bearer ${INFOXMED_VIP_PASSWORD}" \ --get "https://api.infox-med.com/system/batchGenerateVipQr" \ --data-urlencode "agent=${agent}" \ --data-urlencode "count=1" \ --data-urlencode "cardName=${cardName}" \ --data-urlencode "vipCarType=${vipCarType}" \ --data-urlencode "times=${times}" \ -o "$output_file" ``` If the API cannot immediately be changed, ensure query strings are redacted in client, gateway, proxy, monitoring, and server logs, while treating this only as an interim mitigation. 5. **Prevent command and transcript disclosure.** Avoid execution modes that echo expanded commands, ensure error output cannot reproduce the authenticated URL, and configure all relevant logging systems to redact the password. 6. **Rotate exposed credentials.** Any password previously used with the documented workflow should be rotated after the sa ...[truncated 384 chars]
