T09 · Insecure Skill Coding Practices
- Location
scripts/guardian-ask.sh:5- Finding
Unrestricted API URL Override Can Disclose Guardian Bearer Tokens and Sensitive User Data
- Content
View full analysis
/dev/null) || { ``` `scripts/guardian-deadlines.sh:5-6, 13`: ```bash API_URL="${GUARDIAN_API_URL:-https://guardian-compliance.fly.dev}" TOKEN="${GUARDIAN_TOKEN:-}" timeline=$(curl -sf -H "Authorization: Bearer $TOKEN" "$API_URL/api/dashboard/timeline" 2>/dev/null) || { ``` `scripts/guardian-documents.sh:5-6, 13`: ```bash API_URL="${GUARDIAN_API_URL:-https://guardian-compliance.fly.dev}" TOKEN="${GUARDIAN_TOKEN:-}" docs=$(curl -sf -H "Authorization: Bearer $TOKEN" "$API_URL/api/dashboard/documents" 2>/dev/null) || { ``` `scripts/guardian-risks.sh:5-6, 13`: ```bash API_URL="${GUARDIAN_API_URL:-https://guardian-compliance.fly.dev}" TOKEN="${GUARDIAN_TOKEN:-}" timeline=$(curl -sf -H "Authorization: Bearer $TOKEN" "$API_URL/api/dashboard/timeline" 2>/dev/null) || { ``` `scripts/guardian-status.sh:5-6, 13, 18`: ```bash API_URL="${GUARDIAN_API_URL:-https://guardian-compliance.fly.dev}" TOKEN="${GUARD ...[truncated 3477 chars]- Remediation
View remediation
&2 exit 1 ;; esac ``` 3. **Require HTTPS at both the shell-validation and curl layers.** Add curl protocol restrictions: ```bash curl --proto '=https' --proto-redir '=https' ... ``` Hostname allowlisting is still required because HTTPS alone does not prevent sending the token to an attacker-controlled HTTPS server. 4. **Reject unexpected URL components.** Disallow user information, query strings, fragments, unapproved ports, deceptive hostname suffixes, and alternate schemes. Prefer parsing the URL with a reliable URL parser rather than substring or prefix checks. 5. **Avoid forwarding credentials across redirects.** Keep redirects disabled unless the API explicitly requires them. If redirects are enabled later, ensure bearer credentials are never forwarded to a different origin. 6. **Use narrowly scoped and short-lived credentials.** The Guardian service should issue tokens with only the API permissions needed by this Skill, enforce expiration and revocation, and avoid using one broad token for unrelated account operations. 7. **Minimize transmitted question data.** Before invoking `guardian-ask.sh`, inform users that their question is sent to Guardian. Avoid including unnecessary identifiers or document contents, and provide clear consent for transmission of sensitive compliance information. 8. **Do not suppress all curl diagnostics during security failures.** Preserve sanitized error information for troubleshooting while e ...[truncated 64 chars]
