T09 · Insecure Skill Coding Practices
- Location
lib/kraken_validate.sh:3- Finding
Authenticated API requests can be redirected to arbitrary configured hosts
- Content
View full analysis
Vulnerability Details
File Location:
lib/kraken_validate.sh:3-12,lib/kraken_http.sh:22-32,43-50, andlib/kraken_futures.sh:94-120,135-142
Vulnerability Type: Insufficient destination validation for credential-bearing requests
Risk Level: HighVulnerable Code
lib/kraken_validate.sh:3-12:bash kraken_validate_runtime() { case "$KRAKEN_API_BASE_URL" in https://*) ;; http://*) [ "$KRAKEN_ALLOW_INSECURE_BASE_URL" = "true" ] || kraken_fail "refusing insecure base URL without KRAKEN_ALLOW_INSECURE_BASE_URL=true" ;; *) kraken_fail "invalid base URL: $KRAKEN_API_BASE_URL" ;; esaclib/kraken_http.sh:22-32,43-50:bash local nonce="" request_body="$payload" request_url="${KRAKEN_API_BASE_URL}/${KRAKEN_API_VERSION}${path}" signature="" local -a args args=(-sS --connect-timeout "$KRAKEN_TIMEOUT_SECS" --max-time "$KRAKEN_TIMEOUT_SECS" -A "$KRAKEN_USER_AGENT" -X "$method") if [ "$signed" = "true" ]; then nonce="$(kraken_generate_nonce)" request_body="$(kraken_join_query "$(kraken_query_kv nonce "$nonce")" "$payload" "$(kraken_query_kv otp "${KRAKEN_OTP:-}")")" signature="$(kraken_sign_payload "$path" "$request_body" "$nonce")" args+=(-H "API-Key: $KRAKEN_API_KEY" -H "API-Sign: $signature" -H "Content-Type: application/x-www-form-urlencoded" --data "$request_body") elif [ -n "$payload" ]; then request_url="${request_url}?${payload}" fi kraken_log info "dispatching ${method} ${request_url}" set +x if [ "${KRAKEN_OUTPUT_MODE:-raw}" = "raw" ] && [ -z "${KRAKEN_JQ_FILTER:-}" ]; then "$KRAKEN_HTTP_BIN" "${args[@]}" "$request_url" return fi response="$("$KRAKEN_HTTP_BIN" "${args[@]}" "$request_url")"lib/kraken_futures.sh:94-120,135-142:bash kraken_futures_http_request() { local method="$1" local path="$2" local payload="${3:-}" local signed="$4" local nonce="" ...[truncated 3058 chars]- Remediation
View remediation
Remediation Suggestions
- Parse URLs using a robust URL parser instead of shell prefix matching.
- Allowlist exact approved origins, such as the intended Kraken API hostnames, with HTTPS and the expected port.
- Reject user-information components, fragments, unexpected ports, malformed hosts, and hostnames that merely contain a trusted name as a suffix or prefix.
- Apply equivalent validation to
KRAKEN_FUTURES_API_BASE_URLbefore any request is prepared. - Do not attach private authentication headers when the destination differs from an approved Kraken origin.
- If custom endpoints are required for local testing, place them behind a clearly named test-only option and prohibit real credentials while that option is active.
- Add tests proving that attacker-controlled HTTPS hosts, deceptive hostname suffixes, user-information URLs, and unapproved ports are rejected for authenticated requests.
