T09 · Insecure Skill Coding Practices
- Location
scripts/transcribe.py:45- Finding
Unrestricted URL Retrieval Enables Server-Side Request Forgery and Resource Exhaustion
- Content
View full analysis
str: ext = os.path.splitext(url.split("?")[0])[1] or ".ogg" tmp = tempfile.NamedTemporaryFile(suffix=ext, delete=False) urllib.request.urlretrieve(url, tmp.name) return tmp.name ``` The URL is accepted directly from the command line and then passed to the downloader: ```python src.add_argument("--url", help="Direct audio URL") ``` ```python elif args.url: tmp_path = download_url(args.url) audio_path = tmp_path ``` In default API mode, the downloaded content is subsequently opened and sent to OpenAI: ```python with open(audio_path, "rb") as f: result = client.audio.transcriptions.create(file=f, **kwargs) ``` ```python if args.local: result = transcribe_local(audio_path, args.language, args.model) else: if not args.openai_key: raise RuntimeError("OPENAI_API_KEY not set (or use --local for free mode)") result = transcribe_api(audio_path, args.language, args.openai_key) ``` ### Technical Analysis The `--url` argument is treated as a trusted direct audio location. The implementation does not: - Enforce the documented HTTPS-only expectation. - Restrict accepted URL schemes. - Reject loopback, private, link-local, multicast, or reserved destinations. - Revalidate destinations following redirects. - Set an explicit timeout for this download. - Limit the number of downloaded bytes. - Validate the response MIME type, file signature, or actual audio format. - Confirm that the retrieved resource is appropriate for transcription. This creates a server-side request forgery primitive whenever an attacker can influence the URL passed ...[truncated 2270 chars]- Remediation
View remediation
