T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:179- Finding
Unrestricted PDF URL handling permits SSRF and local file disclosure
- Content
View full analysis
Dict[str, Any]: """Download a PDF to a temporary file with curl. curl is used here intentionally so the behavior matches the user's desired workflow: try a real file download first, then decide how to attach it. """ filename = safe_filename_from_url(pdf_url) temp_dir = tempfile.mkdtemp(prefix='arxiv_to_zotero_') target = Path(temp_dir) / filename command = [ 'curl', '--location', '--fail', '--silent', '--show-error', '--max-time', str(max(10, int(timeout))), '--output', str(target), pdf_url, ] try: completed = subprocess.run(command, capture_output=True, text=True, check=False) ``` URL candidates are not restricted to approved schemes or hosts: ```python def resolve_pdf_candidates_from_item_url(item_url: str | None) -> List[str]: """Build likely PDF URLs from the parent item's saved URL.""" candidates: List[str] = [] def add(url: str | None) -> None: value = (url or "").strip() if not value: return value = value.replace("http://", "https://") if value not in candidates: candidates.append(value) raw_url = (item_url or "").strip() if not raw_url: return candidates normalized = raw_url.replace("http://", "https://") if normalized.lower().endswith(".pdf"): add(normalized) return candidates if "arxiv.org/abs/" in normalized: base = normalized.replace("/abs/", "/pdf/") add(base + ".pdf" if not base.endswith(".pdf") else base) add(base[:-4] if base.endswith(".pdf") else base) return candidates if "arxiv.org ...[truncated 2829 chars]- Remediation
View remediation
