Tainted flow: 'req' from os.environ.get (line 2813, credential/environment) → urllib.request.urlopen (network output)
- Category
- Data Flow
- Confidence
- 90% confidence
- Finding
Sending the API key to the default HTTPS service is legitimate authentication, not inherently exfiltration. However, build_client accepts an unrestricted --base-url or QIANLIMA_BASE_URL, and _request attaches the environment-held API key without validating the destination or requiring HTTPS; an attacker who influences that configuration can capture the key through an attacker-controlled endpoint or plaintext connection. add_unredirected_header protects against forwarding the key on redirects, but not against a malicious initial destination.
- Content
python if self.api_key: req.add_unredirected_header("qianlimaApiKey", self.api_key) try: with urllib.request.urlopen(req, timeout=30) as resp: payload = json.loads(resp.read().decode("utf-8")) except urllib.error.HTTPError as exc: # HTTP errors may contain the authoritative business error and limits.
