T09 · Insecure Skill Coding Practices
- Location
scripts/wechat_skill/extractors.py:119- Finding
Unrestricted URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
bool: return bool(re.match(r"^https?://", (value or "").strip(), re.I)) ``` ```python def extract_from_url(url: str, timeout: int = 30) -> Article: response = requests.get(url, timeout=timeout, headers={"User-Agent": "Mozilla/5.0"}) response.raise_for_status() soup = BeautifulSoup(response.text, "html.parser") if "mp.weixin.qq.com" in url: return _extract_weixin_article(soup, url) return _extract_generic_article(soup, url) def load_article(input_value: str, timeout: int = 30) -> Article: if is_url(input_value): return extract_from_url(input_value, timeout=timeout) path = Path(input_value).resolve() if not path.exists(): raise RuntimeError(f"File does not exist: {path}") return _load_markdown_file(path) ``` The vulnerable function is directly reachable through the following CLI inputs: - `extract ` - `draft ` - `workflow --source-url ` ### Technical Analysis The URL check only verifies that the supplied value begins with `http://` or `https://`. It does not restrict the destination hostname, resolve and inspect the destination IP address, or reject loopback, private, link-local, multicast, and other reserved address ranges. The request also follows HTTP redirects under the default `requests` behavior. Consequently, checking only the original textual URL would not be sufficient: a public endpoint could redirect the request to a private service. The fetched response is parsed and can be written to generated Markdown or workflow assets. This makes the primitive useful not only for blind network probing but also, where the response resembles parseable HTML, for retrieving information from services accessible to the machine running the ...[truncated 1337 chars]- Remediation
View remediation
