T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:43
- Finding
- Overly Broad API Route and HTTP Method Authorization<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 43–68 **Vulnerability Type**: Insufficient route and method allowlisting **Risk Level**: Medium ### Vulnerable Code ```bash [ "${#args[@]}" -ge 1 ] || { echo "usage: crawlora.sh [-X METHOD] /path [k=v ... | json-body]" >&2; exit 2; } path="${args[0]}" rest=("${args[@]:1}") # This skill's helper is limited to its documented Crawlora route set. Keep # caller-account surfaces and unrelated API routes out of the helper even if # someone supplies an undocumented path directly. case "$method" in GET|POST) ;; *) echo "only GET and POST are supported by the costco-research skill" >&2 exit 2 ;; esac # Reject path syntax that could smuggle a route through a shell glob check. case "$path" in ""|*[?#%]*|*..*|*//* ) echo "invalid path for the costco-research skill" >&2 exit 2 ;; esac case "$path" in /costco/categories) ;; /costco/product/*) ;; /costco/product/*/availability) ;; /costco/product/*/reviews) ;; /costco/search) ;; /costco/warehouses) ;; *) echo "path is not in the costco-research skill catalog" >&2 exit 2 ;; esac ``` ### Technical Analysis The endpoint reference documents six read-only `GET` endpoints, but the helper authorizes both `GET` and `POST` for all accepted paths. POST access is not necessary for the Skill’s declared Costco research functionality. The route pattern `/costco/product/*` is also broader than the documented `/costco/product/{id}` route. In a shell `case` pattern, `*` can match slash characters and multiple path segments. Consequently, this pattern accepts arbitrary nested paths such as `/costco/product/123/undocumented-route`. Because it appears before the more specific availability and reviews patterns, those later patterns do not constrain product subroutes. Requests accepted through this broad allowlist are authenticated with the user's `CRAWLORA_API_KEY`. The fixed HTTPS origin prevents redir ...[truncated 1686 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove POST support because every endpoint documented in `reference/endpoints.md` uses GET: ```bash [ "$method" = "GET" ] || { echo "only GET is supported by the costco-research skill" >&2 exit 2 } ``` 2. Replace the broad `/costco/product/*` pattern with explicit route validation that permits exactly one product-ID segment: - `/costco/product/{id}` - `/costco/product/{id}/availability` - `/costco/product/{id}/reviews` 3. Validate product IDs against the narrowest format supported by Costco, preferably numeric-only if that is guaranteed by the API. At minimum, reject empty IDs and IDs containing `/`. 4. Keep the exact allowlist for: - `/costco/categories` - `/costco/search` - `/costco/warehouses` 5. Add negative tests confirming rejection of: - Every POST request. - `/costco/product/123/extra` - `/costco/product/123/reviews/extra` - Empty or multi-segment product IDs. - Undocumented account, billing, or administrative routes. 6. Retain the existing fixed HTTPS API origin, restricted API-key format, private temporary configuration file, and rejection of curl file-upload syntax. ]]>
