T09 · Insecure Skill Coding Practices
- Location
web-search.sh:165- Finding
Untrusted API Content Is Interpreted as Terminal Escape Sequences
- Content
View full analysis
/dev/null | head -5) # Later output sinks echo -e " $ANSWER" echo -e " $ABSTRACT" echo -e " $DEFINITION" echo "$RELATED_TOPICS" | while read -r topic; do if [ -n "$topic" ] && [ "$topic" != "" ]; then topic_clean=$(echo "$topic" | sed -E 's/]*href="([^"]*)"[^>]*>([^<]*)<\/a>/\2 (\1)/g' | sed 's/<[^>]*>//g') if [ "$OUTPUT_FORMAT" = "markdown" ]; then echo "- $topic_clean" else echo -e " • $topic_clean" fi fi done | head -n "$MAX_RELATED" ``` ### Technical Analysis The script treats fields returned by the DuckDuckGo API as trusted terminal text. Although some fields have carriage returns and line feeds removed, this does not remove other control characters. Moreover, `echo -e` interprets backslash escape notation contained in its arguments. Consequently, a response containing an actual escape character or text such as `\033]...` can cause the terminal to interpret the response as a control sequence rather than display it as inert text. Removing HTML tags from related topics does not mitigate terminal escape-sequence injection. Potential terminal-dependent effects include: - Rewriting or hiding displayed output. - Forging status messages or result boundaries. - Changing terminal titles or hyperlinks. - Trigg ...[truncated 1644 chars]- Remediation
View remediation
