T09 · Insecure Skill Coding Practices
- Location
scripts/unidoc_parse.py:343- Finding
Unrestricted Server-Controlled URL Enables Server-Side Request Forgery
- Content
View full analysis
- Remediation
View remediation
str: parsed = urlparse(value) if parsed.scheme != "https": raise ValueError("Export URL must use HTTPS") if parsed.username or parsed.password: raise ValueError("Credentials are not allowed in export URLs") if parsed.hostname not in ALLOWED_EXPORT_HOSTS: raise ValueError("Untrusted export hostname") for result in socket.getaddrinfo(parsed.hostname, parsed.port or 443): address = ipaddress.ip_address(result[4][0]) if ( address.is_private or address.is_loopback or address.is_link_local or address.is_reserved or address.is_multicast or address.is_unspecified ): raise ValueError("Export URL resolves to a prohibited address") return value ` ...[truncated 106 chars]
