T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/crawlora.sh:34
- Finding
- Authenticated POST Requests Exceed the Skill's Declared API Scope<![CDATA[ ## Vulnerability Details **File Location**: `scripts/crawlora.sh`, lines 34–49 and 91–98 **Vulnerability Type**: Excessive HTTP method permissions and out-of-contract authenticated requests **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 amazon-jobs-research skill" >&2 exit 2 ;; esac ``` ```bash else [ -n "$body" ] || body="${rest[0]:-}" [ -n "$body" ] || body='{}' # Stream the body on stdin so curl never interprets a user value as its # @file shorthand (and cannot read local files supplied in a request body). printf '%s' "$body" | curl -fsS -X "$method" "${auth[@]}" \ -H "Content-Type: application/json" --data-binary @- "${base}${path}" fi ``` ### Technical Analysis The helper accepts `POST` through the `-X` option and attaches the user's `CRAWLORA_API_KEY` to the resulting request. It also permits an arbitrary JSON body to be supplied through `-d` or a positional argument. This behavior exceeds the minimum permissions required by the Skill. The endpoint specification in `reference/endpoints.md` defines only these operations: - `GET /amazon-jobs/job` - `GET /amazon-jobs/search` No POST operation is documented or required for Amazon job search or job-detail retrieval. Although the helper fixes the destination to `https://api.crawlora.net/api/v1` and allowlists the two route paths, those controls do not prevent an aut ...[truncated 2034 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Enforce a route-to-method policy that permits only the methods declared in `reference/endpoints.md`. For this Skill, both routes should accept only GET. Recommended hardening steps: 1. Remove support for `POST`, `-X`, `-d`, and arbitrary request bodies from this helper. 2. Reject any explicit method other than GET. 3. Retain the fixed HTTPS base URL and exact route allowlist. 4. Add regression tests confirming that POST, PUT, PATCH, DELETE, and malformed method values are rejected before curl is executed. 5. Keep the existing API-key safeguards, private temporary configuration, and `@` rejection. A minimal policy could be implemented as follows: ```bash method="GET" while [ $# -gt 0 ]; do case "$1" in -X|-d) echo "custom methods and request bodies are not supported by the amazon-jobs-research skill" >&2 exit 2 ;; *) args+=("$1") shift ;; esac done case "$path" in /amazon-jobs/job|/amazon-jobs/search) ;; *) echo "path is not in the amazon-jobs-research skill catalog" >&2 exit 2 ;; esac ``` The request should then always use the GET branch, ensuring the helper cannot issue authenticated operations beyond the documented Skill functionality. ]]>
