T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/configuration-available-regions.sh:12
- Finding
- Unvalidated Custom API Base URL Can Disclose the TripGo API Key<![CDATA[ ## Vulnerability Details **File Location**: `scripts/configuration-available-regions.sh:12, 58-60, 92-97` Additional affected locations: - `scripts/configuration-pois-for-a-transport-mode.sh:12, 85-87, 122-125` - `scripts/configuration-tsps-per-region.sh:13, 47-49, 81-86` - `scripts/geocode-search-and-autocompletion.sh:11, 134-136` - `scripts/locations-additional-details-for-a-coordinate.sh:13, 58-60` - `scripts/locations-pois-for-a-circular-region.sh:12, 47-49` - `scripts/public-transport-departure-timetable-for-a-stop.sh:15, 102-104` - `scripts/public-transport-details-of-a-route.sh:15, 63-65` - `scripts/public-transport-get-details-of-a-service.sh:15, 85-86` - `scripts/public-transport-get-real-time-alerts.sh:15, 49-50` - `scripts/public-transport-operators-for-a-region-or-group-of-regions.sh:15, 99-101` - `scripts/public-transport-real-time-information-for-a-service.sh:18, 61-63` - `scripts/public-transport-routes-for-a-region-or-operator.sh:15, 117-119` - `scripts/public-transport-services-for-a-route.sh:15, 91-93` - `scripts/trips-gets-hooked-urls.sh:9, 28-29` - `scripts/trips-hooks-a-trip-to-real-time-updates.sh:9, 100-101` - `scripts/trips-mark-trip-as-planned-by-a-user.sh:9, 29-30` - `scripts/trips-removes-a-hooks-from-a-trip.sh:9, 28-29` - `scripts/trips-retrieve-previously-computed-trip.sh:9, 26-27` - `scripts/trips-save-trip-for-later-use.sh:9, 28-29` - `scripts/trips-update-trip-with-real-time-data.sh:9, 36-37` - `scripts/ttp-delete-travelling-tourist-problem-deprecated.sh:13, 36-37` **Vulnerability Type**: Unvalidated credential destination / sensitive-header disclosure **Risk Level**: Medium ### Vulnerable Code The representative script accepts an unrestricted API base URL from the environment: ```bash # Configuration TRIPGO_API_KEY="${TRIPGO_API_KEY:-}" TRIPGO_BASE_URL="${TRIPGO_BASE_URL:-https://api.tripgo.com/v1}" ``` It also allows the destination to be supplied directly through a command-line argument: ```bash -u|--ba ...[truncated 3319 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Bind credentials to trusted hosts** Permit `X-TripGo-Key` only when the parsed destination hostname exactly matches `api.tripgo.com`, unless an administrator has explicitly configured another trusted hostname. 2. **Require HTTPS** Reject all base URLs that do not use the `https` scheme. Add curl protocol restrictions as defense in depth: ```bash curl --proto '=https' --proto-redir '=https' ... ``` 3. **Validate URLs structurally** Use a reliable URL parser rather than substring or prefix matching. Validate the scheme, normalized hostname, port, user-information component, and path. Avoid checks such as `*tripgo.com*`, which can accept attacker domains such as `tripgo.com.attacker.example`. 4. **Use an explicit endpoint allowlist** If private gateways or test endpoints are required, introduce a separately managed allowlist, such as `TRIPGO_API_HOST_ALLOWLIST`. Custom hosts should require deliberate administrator configuration rather than accepting arbitrary per-call values. 5. **Remove unrestricted command-line destination overrides** Remove `--base-url` where it is not operationally necessary. If retained, apply the same HTTPS and trusted-host validation before constructing any authenticated request. 6. **Validate before adding the credential header** Build the request only after destination validation. Abort without transmitting the API key if validation fails. 7. **Control redirect behavior** The current calls do not explicitly request redirects. Keep redirects disabled unless required. If redirects are enabled later, revalidate every redirect destination and never forward the authentication header to a different origin. 8. **Avoid API keys in command-line arguments** Prefer `TRIPGO_API_KEY` or a protected secret provider over `--api-key`, because command-line arguments may be exposed through process listings, shell history, or automation logs. A hardened validation flow s ...[truncated 575 chars]
