T09 · Insecure Skill Coding Practices
- Location
scripts/download_arxiv.py:160- Finding
Unrestricted Feed-Provided PDF URLs Permit Arbitrary Outbound Requests
- Content
View full analysis
None: req = urllib.request.Request(url, headers={"User-Agent": "arxiv-related-papers-skill/1.0"}) try: with urllib.request.urlopen(req, timeout=timeout, context=_SSL_CONTEXT) as resp: data = resp.read() except urllib.error.URLError as err: _raise_if_bad_cert(err) raise destination.write_bytes(data) ``` ```python pdf_url = entry.get("pdf_url") if not pdf_url: skipped += 1 print(f"[{idx}/{len(entries)}] SKIP no PDF URL: {title}") continue try: download_file(pdf_url, destination) downloaded += 1 print(f"[{idx}/{len(entries)}] DOWNLOADED: {destination.name}") ``` ### Technical Analysis The Atom feed parser treats any link labeled as a PDF, or having the `application/pdf` media type, as a trusted download location. The URL is passed directly to `urllib.request.urlopen` without validating: - The URL scheme - The destination hostname - The destination port - Embedded credentials - Redirect targets - Whether the response is actually a PDF Although the initial API request uses HTTPS with certificate verification, this protection does not establish that every URL contained in the API response points to an approved ...[truncated 1833 chars]- Remediation
View remediation
