T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:41
- Finding
- Overbroad API Route and HTTP Method Allowlist<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 41–72 **Vulnerability Type**: Overbroad authenticated API access caused by permissive wildcard routing and unnecessary HTTP methods **Risk Level**: Medium ### Vulnerable Code ```bash case "$method" in GET|POST) ;; *) echo "only GET and POST are supported by the shop-app-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 shop-app-research skill" >&2 exit 2 ;; esac case "$path" in /shop-app/analysis) ;; /shop-app/categories) ;; /shop-app/products/*) ;; /shop-app/products/*/related) ;; /shop-app/products/*/reviews) ;; /shop-app/products/*/shop) ;; /shop-app/products/*/variant) ;; /shop-app/products/*/variants) ;; /shop-app/search) ;; /shop-app/shops/*) ;; /shop-app/shops/*/collections/*/products) ;; /shop-app/shops/*/locations) ;; /shop-app/shops/*/products) ;; /shop-app/shops/*/reviews) ;; /shop-app/shops/*/typeahead) ;; /shop-app/suggestions) ;; *) echo "path is not in the shop-app-research skill catalog" >&2 exit 2 ;; esac ``` ### Technical Analysis The documented Shop.app catalog contains only GET endpoints, but the helper permits both `GET` and `POST`. Allowing POST therefore exceeds the HTTP privileges required for the Skill's declared read-only public-data research functionality. The route validation also uses Bash glob patterns that are broader than the documented endpoints: - `/shop-app/products/*` - `/shop-app/shops/*` In Bash `case` matching, `*` can match slash characters and arbitrarily many path segments. As a result, `/shop-app/products/*` accepts any nested route beneath `/shop-app/products/`, while `/shop-app/shops/*` accepts any nested route beneath `/shop-app/shops/`. The later, more specific patterns do not narrow these broad matches. The helper subsequent ...[truncated 2390 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Restrict the helper to GET requests unless a documented endpoint explicitly requires another method: ```bash if [ "$method" != "GET" ]; then echo "only GET is supported by the shop-app-research skill" >&2 exit 2 fi ``` 2. Replace broad shell globs with anchored, segment-aware regular expressions. Ensure product IDs, shop handles, and collection IDs each occupy exactly one path segment. 3. Validate the route against explicit endpoint shapes, for example: ```bash if [[ "$path" =~ ^/shop-app/(analysis|categories|search|suggestions)$ ]] || [[ "$path" =~ ^/shop-app/products/[^/]+$ ]] || [[ "$path" =~ ^/shop-app/products/[^/]+/(related|reviews|shop|variant|variants)$ ]] || [[ "$path" =~ ^/shop-app/shops/[^/]+$ ]] || [[ "$path" =~ ^/shop-app/shops/[^/]+/(locations|products|reviews|typeahead)$ ]] || [[ "$path" =~ ^/shop-app/shops/[^/]+/collections/[^/]+/products$ ]]; then : else echo "path is not in the shop-app-research skill catalog" >&2 exit 2 fi ``` 4. Apply conservative character allowlists and length limits to dynamic path segments where the API's identifier formats are known. 5. Add negative tests confirming rejection of: - POST requests. - Extra nested path segments. - Undocumented routes under product and shop prefixes. - Empty identifiers and malformed handles. - Query strings embedded directly in the path. 6. Retain the existing fixed HTTPS base URL, mode-600 temporary curl configuration, cleanup trap, and `@` rejection because these are useful defense-in-depth controls. ]]>
