T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:46
- Finding
- Overly Broad Route and HTTP Method Allowlisting Permits Undocumented Authenticated API Requests<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 46–88 **Vulnerability Type**: Improper input validation and ineffective API route allowlisting **Risk Level**: Medium ### Vulnerable Code ```bash case "$method" in GET|POST) ;; *) echo "only GET and POST are supported by the developer-oss-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 developer-oss-research skill" >&2 exit 2 ;; esac case "$path" in /chromewebstore/categories) ;; /chromewebstore/category) ;; /chromewebstore/charts) ;; /chromewebstore/collection) ;; /chromewebstore/developer) ;; /chromewebstore/item) ;; /chromewebstore/permissions) ;; /chromewebstore/privacy) ;; /chromewebstore/reviews) ;; /chromewebstore/search) ;; /chromewebstore/similar) ;; /chromewebstore/suggest) ;; /github/org/*) ;; /github/org/*/repos) ;; /github/repo/*/*) ;; /github/repo/*/*/contributors) ;; /github/repo/*/*/forks) ;; /github/repo/*/*/languages) ;; /github/repo/*/*/releases) ;; /github/search/repositories) ;; /github/search/users) ;; /github/trending) ;; /github/trending/developers) ;; /github/user/*) ;; /github/user/*/events) ;; /github/user/*/followers) ;; /github/user/*/following) ;; /github/user/*/pinned) ;; /github/user/*/repos) ;; *) echo "path is not in the developer-oss-research skill catalog" >&2 exit 2 ;; esac ``` ### Technical Analysis Bash `case` patterns use shell glob semantics, where `*` can match slash characters as well as ordinary characters. Consequently, ostensibly narrow patterns such as: ```bash /github/user/* /github/org/* /github/repo/*/* ``` do not enforce the expected number of path segments. For example, they can accept paths such as: ```text /github/user/alice/undocumented/action /github/org/example/undocumented/action /github/ ...[truncated 2653 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Enforce exact path shapes.** Validate dynamic segments separately and ensure they cannot contain `/`. For example, restrict GitHub owner, repository, organization, and username segments to the character set accepted by the upstream service. 2. **Use anchored regular expressions instead of broad shell globs.** Example: ```bash if [[ "$path" =~ ^/github/user/[A-Za-z0-9-]+$ ]]; then : elif [[ "$path" =~ ^/github/user/[A-Za-z0-9-]+/(events|followers|following|pinned|repos)$ ]]; then : elif [[ "$path" =~ ^/github/org/[A-Za-z0-9-]+$ ]]; then : elif [[ "$path" =~ ^/github/org/[A-Za-z0-9-]+/repos$ ]]; then : elif [[ "$path" =~ ^/github/repo/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$ ]]; then : elif [[ "$path" =~ ^/github/repo/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/(contributors|forks|languages|releases)$ ]]; then : else echo "path is not in the developer-oss-research skill catalog" >&2 exit 2 fi ``` 3. **Bind HTTP methods to individual endpoints.** Since the current endpoint reference documents only GET operations, reject POST entirely unless a specific POST endpoint is later introduced: ```bash [ "$method" = "GET" ] || { echo "only GET is supported by this skill catalog" >&2 exit 2 } ``` 4. **Prefer a structured endpoint table.** Store each route pattern together with its allowed method rather than validating the method and route independently. 5. **Add negative security tests** covering: - Additional path segments after usernames, organizations, and repositories. - Empty dynamic path segments. - POST requests to every GET-only endpoint. - Encoded separators and traversal-like syntax. - Valid documented routes to prevent regressions. ]]>
