T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/configuration-available-regions.sh:12
- Finding
- TripGo API Credential Disclosure Through Unrestricted Base URL Overrides<![CDATA[ ## Vulnerability Details **File Location**: - `scripts/configuration-available-regions.sh:12,58-60,94-97` - `scripts/configuration-pois-for-a-transport-mode.sh:12,85-87,124-125` - `scripts/configuration-tsps-per-region.sh:13,47-49,83-86` - `scripts/geocode-search-and-autocompletion.sh:10-11,104,134-136` - `scripts/locations-additional-details-for-a-coordinate.sh:12-13,58-60` - `scripts/locations-pois-for-a-circular-region.sh:11-12,47-49` - `scripts/public-transport-departure-timetable-for-a-stop.sh:14-15,102-105` - `scripts/public-transport-details-of-a-route.sh:14-15,63-66` - `scripts/public-transport-get-details-of-a-service.sh:14-15,85-86` - `scripts/public-transport-get-real-time-alerts.sh:14-15,49-50` - `scripts/public-transport-operators-for-a-region-or-group-of-regions.sh:14-15,99-102` - `scripts/public-transport-real-time-information-for-a-service.sh:17-18,61-64` - `scripts/public-transport-routes-for-a-region-or-operator.sh:14-15,117-120` - `scripts/public-transport-services-for-a-route.sh:14-15,91-94` - `scripts/trips-gets-hooked-urls.sh:8-9,28-31` - `scripts/trips-hooks-a-trip-to-real-time-updates.sh:8-9,100-104` - `scripts/trips-mark-trip-as-planned-by-a-user.sh:8-9,29-32` - `scripts/trips-removes-a-hooks-from-a-trip.sh:8-9,28-31` - `scripts/trips-retrieve-previously-computed-trip.sh:8-9,26-29` - `scripts/trips-save-trip-for-later-use.sh:8-9,28-31` - `scripts/trips-update-trip-with-real-time-data.sh:8-9,30,36-39` - `scripts/ttp-delete-travelling-tourist-problem-deprecated.sh:12-13,36-37` **Vulnerability Type**: Credential disclosure through an unrestricted, user-configurable network destination **Risk Level**: Medium ### Vulnerable Code A representative source and sink appear in `scripts/configuration-available-regions.sh`: ```bash TRIPGO_API_KEY="${TRIPGO_API_KEY:-}" TRIPGO_BASE_URL="${TRIPGO_BASE_URL:-https://api.tripgo.com/v1}" ``` The destination can also be changed through a command-line option: ```bash -u|--base-url) TRIPGO_ ...[truncated 3951 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Prefer a fixed official origin** If custom TripGo deployments are not required, remove `TRIPGO_BASE_URL` and `--base-url` support and use a constant HTTPS origin: ```bash readonly TRIPGO_BASE_URL="https://api.tripgo.com/v1" ``` 2. **Require HTTPS** Reject destinations that do not begin with `https://`: ```bash if [[ ! "$TRIPGO_BASE_URL" =~ ^https:// ]]; then echo "Error: TRIPGO_BASE_URL must use HTTPS" >&2 exit 1 fi ``` 3. **Validate the hostname against an explicit allowlist** Parse the URL using a robust URL parser and require the normalized hostname to match an approved TripGo host or explicitly configured enterprise deployment. Do not rely on substring matching, which can accept names such as `api.tripgo.com.attacker.example`. 4. **Separate custom endpoints from credential forwarding** Never attach `X-TripGo-Key` to an untrusted destination. Resolve and validate the destination before constructing the authenticated request. 5. **Constrain curl protocol and redirect behavior** Use settings such as: ```bash curl --proto '=https' \ --proto-redir '=https' \ --max-redirs 0 \ --fail-with-body \ --silent \ --show-error \ ... ``` If redirects are required, validate every redirect destination before forwarding authentication headers. 6. **Avoid API keys in command-line arguments** Remove or discourage `--api-key`, because command-line values may be exposed through process listings and shell history. Prefer a protected environment variable, secure file descriptor, or secret manager. 7. **Fail closed on placeholder credentials** Scripts using values such as `YOUR_API_KEY` or `your-api-key-here` should reject those placeholders explicitly rather than transmitting them. 8. **Apply the validation centrally** Introduce a shared request helper that validates the scheme and hostname and adds authenticatio ...[truncated 439 chars]
