T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/crawlora.sh:38
- Finding
- Overly Broad HTTP Method and API Route Allowlist<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 38–64 **Vulnerability Type**: Insufficient authorization and least-privilege enforcement **Risk Level**: Medium ### Vulnerable Code ```bash method="GET" body="" args=() while [ $# -gt 0 ]; do case "$1" in -X) method="$2"; shift 2 ;; -d) body="$2"; shift 2 ;; *) args+=("$1"); shift ;; esac done [ "${#args[@]}" -ge 1 ] || { echo "usage: crawlora.sh [-X METHOD] /path [k=v ... | json-body]" >&2; exit 2; } path="${args[0]}" rest=("${args[@]:1}") # 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 facebook-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 facebook-research skill" >&2 exit 2 ;; esac case "$path" in /facebook/*) ;; /facebook/marketplace/search) ;; *) echo "path is not in the facebook-research skill catalog" >&2 exit 2 ;; esac ``` The accepted POST request is subsequently transmitted with the user's API key: ```bash printf '%s' "$body" | curl -fsS -X "$method" "${auth[@]}" \ -H "Content-Type: application/json" --data-binary @- "${base}${path}" ``` ### Technical Analysis The skill documentation declares only two operations, both using GET: 1. `GET /facebook/marketplace/search` 2. `GET /facebook/{page}` The helper nevertheless accepts both `GET` and `POST`, and its path check permits every route matching `/facebook/*`. The explicit `/facebook/marketplace/search` branch does not narrow the authorization boundary because that route already matches the preceding `/facebook/*` wildcard. Consequently, the script does not implement the documented endpo ...[truncated 2206 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Restrict the helper to the HTTP methods required by this skill: ```bash [ "$method" = "GET" ] || { echo "only GET is supported by the facebook-research skill" >&2 exit 2 } ``` 2. Replace the broad `/facebook/*` authorization rule with endpoint-specific validation: - Permit `/facebook/marketplace/search` exactly. - Permit only one validated Page identifier segment for Page lookups. - Reject empty identifiers, additional slashes, encoded delimiters, traversal syntax, and query or fragment characters. 3. Prefer separate wrapper functions or commands for Marketplace search and Page lookup rather than accepting arbitrary raw paths. Construct paths internally from validated arguments. 4. Remove POST body handling if no documented endpoint requires it. This reduces the possibility of invoking unintended state-changing operations. 5. Add negative tests confirming rejection of: - POST and other non-GET methods. - Nested paths such as `/facebook/admin/action`. - Unknown Marketplace subroutes. - Paths containing extra segments, traversal tokens, encoded separators, queries, or fragments. 6. Review the server-side API key's permissions and restrict it to the two documented read-only endpoints where Crawlora supports scoped credentials. ]]>
