T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_doc_markdown.py:23- Finding
Trusted-host restriction can be bypassed through automatic HTTP redirects
- Content
View full analysis
str: req = urllib.request.Request(url, headers={"User-Agent": UA}) with urllib.request.urlopen(req, timeout=timeout) as resp: data = resp.read() return data.decode("utf-8", errors="replace") ``` `scripts/refresh_docs_index.py:33-37`: ```python def http_get(url: str, timeout: float) -> str: req = urllib.request.Request(url, headers={"User-Agent": UA}) try: with urllib.request.urlopen(req, timeout=timeout) as resp: data = resp.read() ``` ### Technical Analysis Both network scripts validate the initial URL as HTTPS with the exact hostname `docs.openclaw.ai`. However, `urllib.request.urlopen()` follows HTTP redirects automatically, and neither implementation validates the destination of each redirect. Consequently, a request initially sent to the trusted documentation host can be redirected to an arbitrary external host. This behavior conflicts with the documented constraint that network requests are restricted to `https://docs.openclaw.ai`. Exploitation depends on an attacker being able to influence a redirect returned by the trusted host, such as through compromise, misconfiguration, or a vulnerable documentation route. User-supplied full URLs and off-domain index entries are otherwise correctly rejected. ### Attack Path 1. An attacker gains the ability to cause a URL on `docs.openclaw.ai` to return an HTTP redirect to an attacker-controlled host. 2. The user runs `fetch_doc_markdown.py` for the affected page, or runs `refresh_docs_index.py` when an index endpoint redirects. 3. The script validates only the original `docs.openclaw.ai` URL. 4. `urllib.request.urlopen()` automati ...[truncated 926 chars]- Remediation
View remediation
