T09 · Insecure Skill Coding Practices
- Location
scripts/archiver.py:126- Finding
Server-Side Request Forgery Through Weak Product URL Validation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/archiver.py:126-135,scripts/sources/wsy_source.py:39-45,scripts/sources/source_1688.py:39-45
Vulnerability Type: Server-Side Request Forgery (SSRF)
Risk Level: HighVulnerable Code
scripts/archiver.py:126-135python def _fetch_product_info(self, url: str) -> Optional[Dict]: from sources.wsy_source import WSYSource from sources.source_1688 import Source1688 if 'wsy.com' in url: source = WSYSource() elif '1688.com' in url: source = Source1688() else: logger.error(f"Unsupported source website: {url}") return Nonescripts/sources/wsy_source.py:39-45python def fetch_product(self, url: str, download_images: bool = False) -> Optional[Dict]: logger.info(f"[WSY] Fetching product: {url}") try: self._random_delay() response = self.session.get(url, timeout=30) response.raise_for_status()scripts/sources/source_1688.py:39-45python def fetch_product(self, url: str, download_images: bool = False) -> Optional[Dict]: logger.info(f"[1688] Fetching product: {url}") try: self._random_delay() response = self.session.get(url, timeout=30) response.raise_for_status()Technical Analysis
The entry point determines whether a URL is supported by searching for
wsy.comor1688.comanywhere in the complete URL string. This does not verify the parsed hostname.An attacker can place an approved string in the path, query, fragment, user-information component, or an attacker-controlled hostname. For example,
http://127.0.0.1/service?wsy.compasses the substring test even though its destination is localhost.The source adapter then passes the original URL directly to
requests.Session.get. Requests follows HTTP redirects by default, and the code neither disables red ...[truncated 1762 chars]- Remediation
View remediation
Remediation Suggestions
- Parse URLs with
urllib.parse.urlsplitinstead of applying substring checks. - Require the
httpsscheme and reject URLs containing user-information. - Compare the normalized hostname against an explicit allowlist, such as
www.wsy.comand approved 1688 hosts. If subdomains are supported, validate them using exact DNS-label boundaries rather thanendswithalone. - Resolve all destination hostnames and reject every loopback, private, link-local, multicast, reserved, unspecified, and metadata-service address for both IPv4 and IPv6.
- Disable automatic redirects or manually follow a small number of redirects while applying the complete validation process to every destination.
- Protect against DNS rebinding by connecting only to a validated resolved address and ensuring that the HTTP hostname and TLS certificate remain correct.
- Apply outbound firewall or proxy restrictions so the process cannot contact internal networks or cloud metadata services.
- Add tests covering deceptive hosts, user-information URLs, encoded addresses, IPv6 literals, redirect chains, and DNS rebinding scenarios.
- Parse URLs with
