T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:37
- Finding
- Overbroad HTTP Method and Route Authorization Enables Authenticated Data Transmission<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 37–100 **Vulnerability Type**: Overbroad API authorization and unintended data transmission **Risk Level**: Medium ### Vulnerable Code The helper accepts both `GET` and `POST`, even though all five documented endpoints are GET-only: ```sh case "$method" in GET|POST) ;; *) echo "only GET and POST are supported by the samsclub-research skill" >&2 exit 2 ;; esac ``` Route validation uses broad wildcards rather than enforcing the exact five documented endpoint structures: ```sh case "$path" in /samsclub/category) ;; /samsclub/content/*) ;; /samsclub/departments) ;; /samsclub/product/*) ;; /samsclub/product/*/related) ;; *) echo "path is not in the samsclub-research skill catalog" >&2 exit 2 ;; esac ``` For any accepted non-GET request, arbitrary caller-provided content is transmitted to the fixed third-party API with the user's API key: ```sh 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 endpoint reference defines five Sam's Club operations, all of which use `GET`. No documented functionality requires `POST` requests or arbitrary JSON request bodies. Allowing `POST` therefore exceeds the minimum network privileges necessary for the declared catalog-research functionality. The route allowlist is also broader than the documented interface. Patterns such as `/samsclub/product/*` and `/samsclub/content/*` accept arbitrary suffixes, including undocumented nested paths, provided they avoid the separately prohibited characters. Consequently, the helper does not enforce the exact endpoint shapes or ...[truncated 2439 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Restrict the helper to `GET`, because every documented endpoint is read-only: ```sh [ "$method" = "GET" ] || { echo "only GET is supported by the samsclub-research skill" >&2 exit 2 } ``` 2. Remove request-body processing and reject `-d` entirely. 3. Replace broad wildcard authorization with exact route-shape validation. Validate identifiers before constructing paths, for example: - `/samsclub/departments` - `/samsclub/category` - `/samsclub/content/<numeric-id>` - `/samsclub/product/<documented-product-id>` - `/samsclub/product/<documented-product-id>/related` 4. Enforce endpoint-specific query parameters: - `/samsclub/departments`: no query parameters. - `/samsclub/category`: require `id`; permit only optional integer `page`. - Product and content routes: reject all query parameters unless explicitly documented. 5. Reject duplicate, unknown, or malformed parameters and enforce reasonable identifier and page-length limits. 6. Retain the existing fixed HTTPS API base, API-key character validation, private temporary file, cleanup trap, and rejection of curl `@file` query syntax, as these controls appropriately reduce credential-redirection and local-file disclosure risks. ]]>
