T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/fetch.py:53
- Finding
- Credential-Bearing and Sensitive URLs Can Be Disclosed to Third-Party Services<![CDATA[ ## Vulnerability Details **File Location**: `scripts/fetch.py:53-67, 97-103` **Vulnerability Type**: Incomplete sensitive-data detection and external URL disclosure **Risk Level**: High ### Complete Code Snippet ```python def has_sensitive_query(url: str) -> bool: parsed = urllib.parse.urlparse(url) params = urllib.parse.parse_qsl(parsed.query, keep_blank_values=True) frag = parsed.fragment.lower() for k, v in params: lk = k.lower() lv = (v or '').lower() if lk in SENSITIVE_KEYS: return True if any(s in lk for s in SENSITIVE_KEYS): return True if len(v) > 20 and any(x in lk for x in ['token', 'code', 'sig', 'key', 'auth']): return True if 'bearer' in lv: return True if any(x in frag for x in ['access_token', 'token=', 'session=', 'code=']): return True return False ``` ```python def clean_service_urls(original_url: str): stripped = original_url.replace('https://', '').replace('http://', '') return [ ('jina', f'https://r.jina.ai/http://{stripped}'), ('markdown-new', f'https://markdown.new/{original_url}'), ('defuddle', f'https://defuddle.md/{original_url}'), ] ``` ### Technical Analysis The Skill deliberately sends URLs classified as public to Jina Reader, markdown.new, and defuddle.md. This is consistent with its declared content-cleaning functionality, but the classification does not adequately prevent sensitive information from being transmitted. The sensitive-data check only recognizes a fixed set of query-parameter names and several fragment patterns. It does not reject URL user information such as `https://username:password@example.com/`, and it cannot reliably identify secrets stored under unrecognized parameter names or fragment formats. After classification, `clean_service_urls()` embeds the entire original URL into requests to external services. This includes its query strin ...[truncated 1865 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Reject URLs containing a nonempty `username` or `password` component before any network request. 2. Remove URL fragments before submitting a URL to a third-party service because fragments are unnecessary for normal server-side retrieval. 3. Strip all query parameters by default before third-party processing, or use a narrowly defined allowlist of parameters known to be public. 4. If query preservation is required, require explicit user confirmation after clearly identifying the third-party recipient and the exact sanitized URL. 5. Normalize and validate the URL once, then construct third-party requests from its parsed components rather than using string replacement. 6. Preserve the original HTTPS scheme when instructing a cleaning service to retrieve the target. 7. Avoid sending a URL sequentially to multiple providers unless necessary. Prefer a user-selected provider or an explicitly configured trusted service. 8. Document that third-party processing discloses the destination URL to external providers. 9. Add tests covering URL user information, encoded parameter names, mixed case, duplicate parameters, fragments, signed URLs, and application-specific secret names. ]]>
