T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_arxiv_pdf_text.py:158- Finding
Unrestricted PDF URL Retrieval and User-Controlled Output Directories
- Content
View full analysis
None: req = urllib.request.Request( url, headers={ "User-Agent": "OpenClaw-arxiv-weekly-report/0.1 (Python urllib)" }, ) with urllib.request.urlopen(req, timeout=timeout) as resp, open(output_path, "wb") as f: f.write(resp.read()) ``` ```python ensure_dir(args.pdf_dir) if arxiv_id: base_name = arxiv_id else: base_name = f"arxiv_pdf_{hashed_name(pdf_url)}" pdf_path = os.path.join(args.pdf_dir, f"{safe_filename(base_name)}.pdf") try: if not os.path.exists(pdf_path) or os.path.getsize(pdf_path) == 0: download_file(pdf_url, pdf_path, timeout=args.timeout) ``` ### Technical Analysis When a value supplied through `--pdf-url` does not match the expected arXiv PDF path, `resolve_source()` preserves the URL unchanged. The resulting value is passed directly to `urllib.request.urlopen()`. There is no validation of: - The URL scheme or destination hostname. - The resolved destination address. - Redirect destinations. - Private, loopback, link-local, or cloud metadata addresses. - The r ...[truncated 2584 chars]- Remediation
View remediation
