T09 · Insecure Skill Coding Practices
- Location
scripts/setup.sh:14- Finding
Unsafe Token Handling Enables Credential Disclosure and Shell Profile Injection
- Content
View full analysis
/dev/null; then echo "" echo "⚠️ Token already configured in $SHELL_PROFILE" echo "Updating existing entry..." sed -i '' "s|export MCDCN_MCP_TOKEN=.*|export MCDCN_MCP_TOKEN=\"$TOKEN\"|" "$SHELL_PROFILE" else # Add to profile if [ -n "$SHELL_PROFILE" ]; then echo "" >> "$SHELL_PROFILE" echo "# McDonald's China MCP Token" >> "$SHELL_PROFILE" echo "export MCDCN_MCP_TOKEN=\"$TOKEN\"" >> "$SHELL_PROFILE" echo "✅ Token added to $SHELL_PROFILE" fi fi # Also export for current session export MCDCN_MCP_TOKEN="$TOKEN" echo "" echo "✅ Setup complete!" echo "" echo "To use immediately in current terminal:" echo " export MCDCN_MCP_TOKEN=\"$TOKEN\"" ``` ### Technical Analysis The setup script accepts the MCP bearer token through an ordinary `read` operation rather than silent input, causing the secret to remain visible while entered. It subsequently prints the complete token back to the terminal and stores it in plaintext in a shell startup file. The token is interpolated directly into an `echo` command and a double-quoted `sed` replacement without validation or shell-safe encoding. Tokens containing quotation marks, newline characters, command substitutions, or other shell syntax can alter the generated prof ...[truncated 1842 chars]- Remediation
View remediation
"$HOME/.mcd-cn.env" chmod 600 "$HOME/.mcd-cn.env" ``` 6. Serialize values using a shell-safe mechanism instead of directly interpolating them into executable profile content. Avoid dynamically constructed `sed` commands containing untrusted values. 7. Do not automatically modify shell startup files. If environment integration is required, add only a fixed command that reads a protected credential file. 8. Review and remove any existing exposed tokens from shell profiles and terminal logs, then revoke and regenerate affected tokens. ]]>
