T09 · Insecure Skill Coding Practices
- Location
scripts/mail_invoice_archiver/archive.py:557- Finding
Unrestricted invoice-link fetching enables server-side request forgery and resource exhaustion
- Content
View full analysis
list[str]: urls = URL_PATTERN.findall(message.body_text) if not urls: return [] if not config.download_link_domains: return urls filtered: list[str] = [] for url in urls: for domain in config.download_link_domains: if domain in url: filtered.append(url) break return filtered ``` ```python # scripts/mail_invoice_archiver/archive.py:105-107 if follow_links: for url in extract_urls(message, config): downloaded = _download_link_if_invoice_like(url) ``` ```python # scripts/mail_invoice_archiver/archive.py:557-577 def _download_link_if_invoice_like(url: str) -> AttachmentPayload | str | None: parsed = urllib.parse.urlparse(url) path = parsed.path.lower() if not path.endswith((".pdf", ".xml", ".ofd", ".zip", ".png", ".jpg", ".jpeg")): return None request = urllib.request.Request(url, headers={"User-Agent": "mail-invoice-archiver/1.0"}) try: with urllib.request.urlopen(request, timeout=20) as response: data = response.read() content_type = response.headers.get_content_type() except urllib.error.URLError as exc: return str(exc) filename = Path(parsed.path).name or "downloaded-file" return AttachmentPayload( part_re ...[truncated 3344 chars]- Remediation
View remediation
