T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:43
- Finding
- Overbroad Authenticated API Method and Route Allowlist<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 43-68 **Vulnerability Type**: Insufficient validation of authenticated API requests **Risk Level**: Medium ### Vulnerable Code ```sh # 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 walmart-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 walmart-research skill" >&2 exit 2 ;; esac case "$path" in /walmart/product/*) ;; /walmart/product/*/reviews) ;; /walmart/search) ;; *) echo "path is not in the walmart-research skill catalog" >&2 exit 2 ;; esac ``` ### Technical Analysis The documented API contract contains only three `GET` endpoints: - `/walmart/search` - `/walmart/product/{item_id}` - `/walmart/product/{item_id}/reviews` The helper nevertheless permits both `GET` and `POST` for all accepted paths. It also uses the shell glob `/walmart/product/*` as a route allowlist. In shell pattern matching, `*` can match slash characters, so this rule accepts arbitrary nested paths such as `/walmart/product/123/undocumented`. Because this broad rule appears before the reviews-specific rule, it also matches review paths without enforcing their exact structure. The helper does not require `item_id` to be numeric, despite the Skill documentation identifying it as the numeric component of a Walmart product URL. Consequently, the validation does not enforce the minimum method and route privileges needed for the three declared operations. Requests remain restricted to the fixed HTTPS origin `https://api.crawlora.net/api/v1`, so this flaw does not allow redirecting the API key to an a ...[truncated 1497 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Permit only the HTTP method required by the documented contract: ```sh [ "$method" = "GET" ] || { echo "only GET is supported by the walmart-research skill" >&2 exit 2 } ``` 2. Replace broad shell globs with exact, anchored route validation. Require product IDs to contain digits only: ```sh case "$path" in /walmart/search) ;; /walmart/product/[0-9]*) item_id="${path#/walmart/product/}" case "$item_id" in *[!0-9]*|"") exit 2 ;; esac ;; /walmart/product/[0-9]*/reviews) item_id="${path#/walmart/product/}" item_id="${item_id%/reviews}" case "$item_id" in *[!0-9]*|"") exit 2 ;; esac ;; *) echo "path is not in the walmart-research skill catalog" >&2 exit 2 ;; esac ``` 3. Prefer constructing paths from a small set of named operations and validated parameters rather than accepting a caller-provided path. 4. Add negative tests covering `POST`, empty IDs, nonnumeric IDs, extra path segments, encoded separators, query fragments, and undocumented nested routes. 5. Preserve the existing security controls that fix the HTTPS API origin, avoid redirects, reject curl file-input syntax, and keep the API key out of command-line arguments. ]]>
