Tainted flow: 'req' from os.environ.get (line 96, credential/environment) → urllib.request.urlopen (network output)
- Category
- Data Flow
- Confidence
- 96% confidence
- Finding
Sending the token to the intended API is legitimate, but this request uses urllib's default redirect handling, which can forward the explicitly supplied Authorization header to a different origin. An attacker-controlled redirect, or an untrusted API-base override, could therefore expose the bearer token; the code does not enforce an approved HTTPS destination.
- Content
python headers["Content-Type"] = "application/json" req = urllib.request.Request(url, data=data, method=method, headers=headers) try: with urllib.request.urlopen(req, timeout=timeout) as resp: raw = resp.read(MAX_RESPONSE_BYTES + 1) if len(raw) > MAX_RESPONSE_BYTES: raise ApiError(0, "response-too-large", f"The API response is larger than {MAX_RESPONSE_BYTES} bytes.")
