T09 · Insecure Skill Coding Practices
- Location
scripts/zhipu_fetch.sh:21- Finding
Unsafe JSON Construction Allows Request-Body Injection
- Content
View full analysis
- Remediation
View remediation
&2 exit 1 } if (( TIMEOUT < 1 || TIMEOUT > 300 )); then echo "Error: timeout must be between 1 and 300 seconds" >&2 exit 1 fi case "$RETURN_FORMAT" in markdown|text) ;; *) echo "Error: format must be markdown or text" >&2 exit 1 ;; esac PAYLOAD=$(jq -n \ --arg url "$URL" \ --argjson timeout "$TIMEOUT" \ --argjson no_cache "$NO_CACHE" \ --arg return_format "$RETURN_FORMAT" \ --argjson retain_images "$RETAIN_IMAGES" \ --argjson no_gfm "$NO_GFM" \ --argjson keep_img_data_url "$KEEP_IMG_DATA_URL" \ --argjson with_images_summary "$WITH_IMAGES_SUMMARY" \ --argjson with_links_summary "$WITH_LINKS_SUMMARY" \ '{ url: $url, timeout: $timeout, no_cache: $no_cache, return_format: $return_format, retain_images: $retain_images, no_gfm: $no_gfm, keep_img_data_url: $keep_img_data_url, with_images_summary: $with_images_summary, with_links_summary: $with_links_summary }') ``` 3. If adding `jq` is undesirable, use another available JSON serializer that correctly escapes quotes, backslashes, Unicode, and control characters. Avoid manually assembling JSON. 4. Add tests covering quotes, backslashes, newlines, tabs, duplicate-property injection attempts, nonnumeric timeouts, extreme timeout values, missing argument values, and unsupported output formats. ]]>
