T09 · Insecure Skill Coding Practices
- Location
scripts/lib/client.py:59- Finding
Bearer Token May Be Disclosed Through Cross-Origin HTTP Redirects
- Content
View full analysis
Vulnerability Details
File Location:
scripts/lib/client.py, lines 59-82
Vulnerability Type: Authenticated request redirect without destination validation
Risk Level: MediumVulnerable Code
python def _headers(self): return { "Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json;charset=utf-8", "User-Agent": "OpenClaw-VisionOneTI/1.0", } def _request(self, method, path, params=None, body=None): url = f"{self.base_url}{path}" if params: # Filter out None values clean = {k: v for k, v in params.items() if v is not None} if clean: url += "?" + urlencode(clean) data = None if body is not None: data = json.dumps(body).encode("utf-8") req = urllib.request.Request( url, data=data, headers=self._headers(), method=method, ) last_err = None for attempt in range(MAX_RETRIES): try: with urllib.request.urlopen(req, timeout=60) as resp:Technical Analysis
The initial API destination is appropriately constrained through a fixed region-to-hostname mapping and HTTPS. Sending
VISION_ONE_API_KEYas a Bearer token to the selected Trend Micro Vision One endpoint is necessary for the Skill’s declared functionality and does not, by itself, exceed minimum privilege requirements.The security issue arises because
urllib.request.urlopen()uses automatic HTTP redirect handling. The code does not inspect redirect responses or validate the scheme, hostname, and port of the redirect destination. Request headers may be copied to the redirected request, including theAuthorizationheader.Consequently, if an approved API endpoint returns a redirect to another origin, the client may forward the Vision One Bearer token to that destination. Exploitation requires control or compromise of the trusted A ...[truncated 1681 chars]
- Remediation
View remediation
Remediation Suggestions
Replace unrestricted automatic redirect handling with an explicit redirect policy:
- Disable automatic redirects or implement a custom
urllib.request.HTTPRedirectHandler. - Parse every redirect destination with
urllib.parse.urlparse. - Require the destination scheme to remain
https. - Require the destination hostname to exactly match the hostname selected from the fixed
REGIONSmapping. - Reject redirects to unapproved hosts, IP literals, nonstandard ports, embedded credentials, or downgraded HTTP destinations.
- Remove the
Authorizationheader whenever the origin changes, even if cross-origin redirects are permitted for another reason. - Set a small redirect limit and reject redirect loops.
- Add tests covering same-origin redirects, cross-origin redirects, HTTPS-to-HTTP downgrades, hostname suffix tricks, and port changes.
- Continue using separate least-privilege API keys: use a view-only token for read commands and a distinct configuration-capable token only when write functionality is required.
- Disable automatic redirects or implement a custom
