T09 · Insecure Skill Coding Practices
- Location
scripts/search.sh:13- Finding
Unvalidated Result Limit Allows jq Program Injection
- Content
View full analysis
- Remediation
View remediation
100 )); then echo "Error: limit must be an integer between 1 and 100" >&2 exit 1 fi ``` Pass the value to jq as data instead of constructing jq source code: ```bash curl -fsSL "http://${HOST}:${PORT}/search?q=${QUERY}&format=${FORMAT}" | jq --argjson limit "$LIMIT" \ '.results[:$limit] | .[] | {title, url, engine}' ``` For additional hardening: - Validate `SEARXNG_FORMAT` against an explicit allowlist. - Use curl's URL encoding facilities for the query rather than directly embedding it in the URL. - Use `-f` so HTTP errors cause curl to fail. - Enable strict shell behavior where appropriate, such as `set -euo pipefail`. ]]>
