T09 · Insecure Skill Coding Practices
- Location
scripts/collect_publications.py:477- Finding
<![CDATA[Unrestricted homepage requests enable server-side request forgery]]>
- Content
View full analysis
bytes | None: request_headers = {"User-Agent": DEFAULT_UA} if headers: request_headers.update(headers) last_error = None for attempt in range(retries): try: req = urllib.request.Request(url, headers=request_headers) with urllib.request.urlopen(req, timeout=timeout, context=SSL_CONTEXT) as response: if log: final_url = response.geturl() if final_url not in log.fetched_urls: log.fetched_urls.append(final_url) return response.read() ``` ```python def collect_from_homepage(args: argparse.Namespace, log: FetchLog) -> list[dict[str, Any]]: if not args.homepage: return [] homepage = args.homepage first_html = request_text(homepage, timeout=args.timeout, log=log) if not first_html: return [] pages = discover_homepage_pages(homepage, first_html, args.max_homepage_pages) page_html = {homepage: first_html} pubs: list[dict[str, Any]] = [] for page in pages: html_text = page_html.get(page) if html_text is None: html_text = request_text(page, timeout=args.timeout, log=log) ``` ### Technical Analysis The user-controlled `--homepage` value is passed directly to `urllib.request.urlopen`. The implementation does not restrict the URL scheme to secure web requests, resolve and validate the destination address, block private or link-local networks, or revalidate redirect destinations. Although discovered secondary pages are limited to ...[truncated 1533 chars]- Remediation
View remediation
