T09 · Insecure Skill Coding Practices
- Location
scripts/transcribe.py:74- Finding
<![CDATA[Unrestricted URL Retrieval Enables SSRF and Local Resource Access]]>
- Content
View full analysis
bytes: handlers = [] if proxy: p = f"http://{proxy}" handlers.append(urllib.request.ProxyHandler({"http": p, "https": p})) opener = urllib.request.build_opener(*handlers) req = urllib.request.Request(url, headers=UA) with opener.open(req, timeout=timeout) as r: return r.read() def download(url: str, dest: Path, proxy: str | None = None) -> None: if dest.exists() and dest.stat().st_size > 0: print(f"[cache] {dest.name} already downloaded") return print(f"[download] {url[:100]}...") data = http_get(url, proxy=proxy, timeout=300) dest.write_bytes(data) print(f"[download] saved {dest} ({len(data)/1e6:.1f} MB)") ``` The direct-audio path passes an untrusted URL directly to the vulnerable retrieval function: ```python if args.audio: title = args.title or Path(urllib.parse.urlparse(args.audio).path).stem or "episode" slug = args.slug or slugify(title) out_dir = Path(args.out) if args.out else default_out_dir(slug) out_dir.mkdir(parents=True, exist_ok=True) audio_path = out_dir / f"raw{audio_ext_from_url(args.audio)}" download(args.audio, audio_path, proxy=args.proxy) transcribe_downloaded_audio(audio_path, out_dir, args) print(f"[dir] {out_dir}") return ``` Bare feed URLs and URLs supplied by RSS content are also fetched without destination validation: ```python else: print(f"[rss] treating input as a feed URL: {url[:100]}") resolved = {"title": None, "feed": url} feed_xml = http_get(resolved["feed"], proxy=args.proxy) title = args.title or resolved["title"] if title: ...[truncated 3301 chars]- Remediation
View remediation
