T09 · Insecure Skill Coding Practices
- Location
scripts/image_harness.py:92- Finding
Google OAuth Bearer Token Disclosed to Untrusted Response-Supplied URLs
- Content
View full analysis
bool: cmd = ['curl', '-sS', '-L', uri, '-o', out_path] if token: cmd[1:1] = ['-H', f'Authorization: Bearer {token}'] proc = subprocess.run(cmd, capture_output=True) return proc.returncode == 0 ``` ```python def find_uris(obj): uris = [] if isinstance(obj, dict): for k, v in obj.items(): if isinstance(v, str) and (k.lower().endswith('uri') or v.startswith('http')): uris.append(v) elif isinstance(v, (dict, list)): uris.extend(find_uris(v)) elif isinstance(obj, list): for item in obj: uris.extend(find_uris(item)) return uris uris = find_uris(j) if uris: tmp_out = out_path + '.tmp' ok = download_uri(uris[0], tmp_out, token=token) ``` ### Technical Analysis The script recursively treats every HTTP string, and every string stored under a key ending in `uri`, as a potential image URL. It does not validate the URL scheme, destination hostname, port, or relationship to an approved Google service. The selected URL is passed to `curl` together with a live Google OAuth bearer token. When the URL directly identifies an attacker-controlled server, the bearer token is transmitted in the `Authorization` request header. The use of `-L` also enables redirects, although curl's handling of authorization headers across a cross-origin redirect depends on its version and redirect security behavior. A response-supplied URL should be considered untrusted. The broad URL discovery logic may select metadata, citations, model-generated links, or other non-image URLs. Attaching privileged credentials to such a destination exceeds the minimum permissi ...[truncated 1594 chars]- Remediation
View remediation
