T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:41
- Finding
- Overbroad HTTP Method and Route Allowlist<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 41–65 **Vulnerability Type**: Overbroad API capability exposure **Risk Level**: Medium ### Vulnerable Code ```bash # 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 instagram-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 instagram-research skill" >&2 exit 2 ;; esac case "$path" in /instagram/post/*/*) ;; /instagram/profile/*) ;; /instagram/reels/*) ;; *) echo "path is not in the instagram-research skill catalog" >&2 exit 2 ;; esac ``` ### Technical Analysis The documented API surface contains three read-only endpoints: - `GET /instagram/post/{id}/{post_id}` - `GET /instagram/profile/{username}` - `GET /instagram/reels/{id}` However, the helper permits both `GET` and `POST`. Consequently, an invocation using `-X POST` passes local validation even though no supported endpoint is documented as accepting POST requests. The path allowlist also uses unrestricted shell wildcards. In shell pattern matching, `*` can match slash characters, so these patterns do not enforce the expected number of path segments. For example, paths such as `/instagram/profile/user/extra` and `/instagram/post/id/post/extra` can pass the allowlist. The script therefore enforces route prefixes rather than exact endpoint shapes. The API origin is fixed to `https://api.crawlora.net/api/v1`, so this issue does not allow an attacker to redirect the API key to an arbitrary host. Exploitability instead depends on whether Crawlora exposes undocumented POST handlers or nested routes beneath the accepted ...[truncated 1397 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Restrict the helper to the only documented HTTP method: ```bash if [ "$method" != "GET" ]; then echo "only GET is supported by the instagram-research skill" >&2 exit 2 fi ``` 2. Replace wildcard-prefix validation with exact route-shape validation. Validate each endpoint separately and reject extra path segments. For example, use Bash regular expressions with identifier-specific character sets: ```bash if [[ "$path" =~ ^/instagram/profile/[A-Za-z0-9._]+$ ]]; then route="profile" elif [[ "$path" =~ ^/instagram/reels/[0-9]+$ ]]; then route="reels" elif [[ "$path" =~ ^/instagram/post/[0-9]+/[0-9]+$ ]]; then route="post" else echo "path is not in the instagram-research skill catalog" >&2 exit 2 fi ``` 3. Enforce endpoint-specific query parameters. Permit `max_id` only for the Reels endpoint and reject query arguments for profile and post lookups unless the documented API contract changes. 4. Continue retaining the existing fixed API origin, API-key character validation, private temporary configuration file, and rejection of curl `@file` query syntax. 5. Add regression tests covering unsupported methods, empty identifiers, encoded separators, duplicate slashes, additional path segments, and undocumented query parameters. ]]>
