T09 · Insecure Skill Coding Practices
- Location
scripts/citation_fetch_enricher.py:55- Finding
Arbitrary URL Fetching Enables Server-Side Request Forgery
- Content
View full analysis
dict: result = {'url': url} try: r = requests.get(url, headers={'User-Agent': UA}, timeout=timeout, allow_redirects=True) result['status_code'] = r.status_code result['final_url'] = r.url result['classification'], result['host'] = classify_url(r.url) html = r.text[:400000] meta = parse_meta(html) title = first(meta, TITLE_KEYS) or fallback_title(html) work = first(meta, WORK_KEYS) or urlparse(r.url).netloc.replace('www.', '') author = first(meta, AUTHOR_KEYS) date = first(meta, DATE_KEYS) desc = first(meta, DESC_KEYS) result.update({ 'title': title, 'work': work, 'author': author, 'date': date, 'description': desc, }) result['suggested_cite'] = '{{cite web |title=%s |url=%s |work=%s%s%s}}' % ( title or 'MISSING TITLE', r.url, work or 'MISSING WORK', f' |author={author}' if author else ' |author=', f' |date={date}' if date else ' |date=', ) except Exception as e: result['error'] = f'{type(e).__name__}: {e}' result['classification'], result['host'] = classify_url(url) return result ``` The affected URL collection and invocation path is: ```python def urls_from_args(args) -> list[str]: urls: list[str] = [] if args.urls: urls.extend(args.urls) if args.draft: refs = extract_refs(load_text(args.draft)) for ref in refs[: args.limit]: if ref['urls']: urls.append(ref['urls'][0]) return list( ...[truncated 2911 chars]- Remediation
View remediation
