T09 · Insecure Skill Coding Practices
Error
- Location
- references/ofox-video.sh:122
- Finding
- Environment-Controlled API Base Can Exfiltrate the Bearer Credential<![CDATA[ ## Vulnerability Details **File Location**: `references/ofox-video.sh:122`, `references/ofox-video.sh:1140-1149`, and `references/ofox-video.sh:2366-2371` **Vulnerability Type**: Unrestricted authenticated endpoint override **Risk Level**: High ### Vulnerable Code ```bash API_BASE="${OFOX_API_BASE_URL:-https://api.ofox.ai/v1}" ``` The environment-controlled value is subsequently used for authenticated job creation: ```bash local tmp_body http_code curl_rc body tmp_payload tmp_payload=$(mktemp) printf '%s' "$payload" >"$tmp_payload" tmp_body=$(mktemp) http_code=$(curl -sS -o "$tmp_body" -w '%{http_code}' \ --connect-timeout "$CONNECT_TIMEOUT" --max-time "$CREATE_MAX_TIME" \ -X POST "$API_BASE/videos" \ -H "Authorization: Bearer $OFOX_API_KEY" \ -H "Content-Type: application/json" \ --data-binary @"$tmp_payload") ``` It is also used for authenticated polling: ```bash tmp_body=$(mktemp) http_code=$(curl -sS -o "$tmp_body" -w '%{http_code}' \ --connect-timeout "$CONNECT_TIMEOUT" --max-time "$POLL_MAX_TIME" \ -H "Authorization: Bearer $OFOX_API_KEY" \ "$polling_url") ``` ### Technical Analysis `OFOX_API_BASE_URL` can contain an arbitrary URL. The script does not require HTTPS, verify that the destination belongs to Ofox, reject embedded URL credentials, or require an explicit development mode before honoring the override. Authenticated create and poll requests attach `OFOX_API_KEY` as a bearer credential to URLs derived from this variable. Consequently, anyone able to influence the process environment can redirect the credential and generation payload away from `api.ofox.ai`. This is especially significant because the Skill documentation recommends importing all variables from a dotenv file. A dotenv file may therefore define both a legitimate `OFOX_API_KEY` and a malicious `OFOX_API_BASE_URL`. Although a configurable endpoint can be useful for testing, forwarding a production credential to an unrestricted endpoint exceeds the min ...[truncated 1303 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Use `https://api.ofox.ai/v1` as the only allowed production endpoint. 2. Before sending an authorization header, parse the URL and enforce: - Scheme is exactly `https`. - Hostname is exactly `api.ofox.ai`. - No username or password is embedded in the URL. - Port is the expected HTTPS port unless explicitly required. 3. If custom endpoints are needed for testing, require a separate explicit flag such as `--allow-custom-api-base`. 4. Do not send a production API key to a custom endpoint. Require a separate test credential variable or suppress the authorization header for local mocks. 5. Validate the effective destination immediately before every authenticated request, including create and poll operations. 6. Do not import `OFOX_API_BASE_URL` indirectly when loading the API key. 7. Add regression tests proving that authenticated requests reject HTTP, loopback, private-network, and non-Ofox destinations by default. 8. Rotate the Ofox API key if the script has previously run with an untrusted `OFOX_API_BASE_URL`. ]]>
