T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:36
- Finding
- Undocumented POST Capability Allows Arbitrary Data Transmission<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 36–100 **Vulnerability Type**: Excessive network capability and unrestricted request-body transmission **Risk Level**: Medium ### Vulnerable Code ```bash method="GET" body="" args=() while [ $# -gt 0 ]; do case "$1" in -X) method="$2"; shift 2 ;; -d) body="$2"; shift 2 ;; *) args+=("$1"); shift ;; esac done ``` ```bash case "$method" in GET|POST) ;; *) echo "only GET and POST are supported by the wayfair-research skill" >&2 exit 2 ;; esac ``` ```bash if [ "$method" = "GET" ]; then # -G + --data-urlencode URL-encodes each value (so spaces etc. are safe). qs=() for kv in ${rest[@]+"${rest[@]}"}; do [ -n "$kv" ] || continue # curl treats both @file and name@file forms as local-file input for # --data-urlencode. Reject @ outright so query arguments cannot disclose # local files to the Crawlora API. case "$kv" in *@*) echo "@ is not allowed in query arguments" >&2; exit 2 ;; esac qs+=(--data-urlencode "$kv") done curl -fsS -G "${auth[@]}" ${qs[@]+"${qs[@]}"} "${base}${path}" else [ -n "$body" ] || body="${rest[0]:-}" [ -n "$body" ] || body='{}' # Stream the body on stdin so curl never interprets a user value as its # @file shorthand (and cannot read local files supplied in a request body). printf '%s' "$body" | curl -fsS -X "$method" "${auth[@]}" \ -H "Content-Type: application/json" --data-binary @- "${base}${path}" fi ``` ### Technical Analysis The Skill declares only three Wayfair endpoints, and `reference/endpoints.md` documents all three as GET-only: - `GET /wayfair/categories` - `GET /wayfair/category` - `GET /wayfair/product/{id}` Despite this, the helper accepts `-X POST`, accepts arbitrary caller-controlled content through `-d` or a positional argument, and transmits that content to `https://api.crawlora.net/api/v1`. POST support is therefore unnecessary for the declared Wayfair ...[truncated 2618 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove POST and request-body support because every documented endpoint is GET-only: ```bash method="GET" args=("$@") ``` Reject `-X`, `-d`, and any other option-like arguments. 2. Enforce GET explicitly: ```bash case "${1:-}" in -*) echo "options and alternate HTTP methods are not supported" >&2; exit 2 ;; esac ``` 3. Validate parameters separately for each endpoint: - `/wayfair/categories`: allow only `page`, `page_size`, and `q`. - `/wayfair/category`: allow only `category` and `page`. - `/wayfair/product/{id}`: reject query parameters. 4. Validate product paths strictly, such as requiring a `W`-prefixed identifier with an expected character format rather than allowing every value matched by `/wayfair/product/*`. 5. Reject duplicate, malformed, or unexpected query parameters and apply reasonable length limits to parameter names and values. 6. Add regression tests confirming that: - POST is rejected for every route. - `-d` and arbitrary curl-style options are rejected. - Only documented query parameters are accepted. - The API base cannot be overridden. - The API key remains absent from process arguments and logs. ]]>
