T09 · Insecure Skill Coding Practices
- Location
scripts/mcp-websearch.sh:15- Finding
Documented Result-Count Limit Is Not Enforced
- Content
View full analysis
[count]" exit 1 fi ``` The accepted value is subsequently inserted into the authenticated request without range enforcement: ```bash # Build tool request with user-provided query and count TOOL_REQ=$(jq -n \ --arg query "$QUERY" \ --argjson count "$COUNT" \ '{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "bailian_web_search", "arguments": { "query": $query, "count": $count } } }') send_request "$TOOL_REQ" ``` ### Technical Analysis `SKILL.md` documents a maximum of 20 results per query, but the executable validation only verifies that `COUNT` consists of decimal digits. Consequently, values such as `0`, `21`, or extremely large integers pass local validation and are forwarded to the Alibaba Cloud API using the account's `DASHSCOPE_API_KEY`. This is a missing range-validation weakness at a trust boundary. Documentation and agent-level instructions are not reliable substitutes for validation in the script because the script can be invoked directly, incorrectly, or by an agent that fails to follow the documented constraint. The remote API may independently reject or cap excessive values, but the project does not enforce or verify that behavior. Therefore, the local security and cost-control guarantee stated by the skill is absent. ### Attack Path 1. An attacker or mistaken caller invokes the script with a numeric count greater than the documented maximum, for example: ```bash ./script ...[truncated 1261 chars]- Remediation
View remediation
20 )); then echo "Error: count must be an integer between 1 and 20" >&2 echo "Usage: $0 [count]" >&2 exit 1 fi ``` Additional hardening measures: 1. Keep the executable limit synchronized with the limit documented in `SKILL.md`. 2. Send validation errors to standard error and retain a nonzero exit status. 3. Add automated boundary tests for `0`, `1`, `20`, `21`, nonnumeric input, negative input, and very large integers. 4. Treat upstream validation only as defense in depth; do not depend on the remote service to enforce local quota policy. 5. Consider defining the maximum once as a named constant: ```bash MAX_COUNT=20 ``` Use that constant in validation and generate or verify related documentation during testing. ]]>
