T09 · Insecure Skill Coding Practices
- Location
references/tavily-curl-example.md:34- Finding
Shell Command Injection Through Unescaped Search Queries
- Content
View full analysis
- Remediation
View remediation
1000: raise ValueError("Search query is too long") payload = json.dumps({ "api_key": key, "query": q, "search_depth": "basic", "max_results": 3, }).encode("utf-8") request = urllib.request.Request( "https://api.tavily.com/search", data=payload, headers={"Content-Type": "application/json"}, method="POST", ) with urllib.request.urlopen(request, timeout=15) as response: result = json.load(response) ``` 5. Where supported by the API, transmit credentials in an authorization header rather than in the JSON body. 6. Ensure logs and error messages redact credentials. 7. If an external program must be used, invoke it with an argument array and without a shell. Do not place secrets directly in command-line arguments. 8. Add tests containing quotes, semicolons, command substitution syntax, newlines, and Unicode control characters to confirm that query values cannot alter command execution. ]]>
