T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/fetch.js:45
- Finding
- Unrestricted URL Fetching Enables Server-Side Request Forgery<![CDATA[ ## Vulnerability Details **File Location**: `scripts/fetch.js:45-72`, with user-controlled input entering the vulnerable function through `scripts/main.js:27-35` **Vulnerability Type**: Server-Side Request Forgery (SSRF) **Risk Level**: High ### Vulnerable Code ```javascript function fetchHtml(url) { return new Promise((resolve, reject) => { const protocol = url.startsWith('https') ? https : http; const options = { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8' } }; const req = protocol.get(url, options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { resolve(data); }); }); ``` The input reaches this code without security validation: ```javascript async function processLink(url, options = {}) { console.log(`Processing link: ${url}`); try { const content = await fetch.fetchContent(url); ``` ### Technical Analysis The application performs an HTTP request to a caller-supplied URL without validating the destination. It does not enforce a strict scheme allowlist through structured URL parsing, resolve and inspect the destination IP address, or reject loopback, private, link-local, multicast, and reserved address ranges. The platform-recognition logic does not provide a security boundary. Unknown destinations are handled by the generic fetching strategy and therefore remain reachable. An attacker can consequently direct the process to HTTP services that are inaccessible from the attacker's own network but accessible from the environment running the Skill. The implementation also lacks controls against DNS rebinding. If redirect support is added ...[truncated 1378 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse all input using `new URL(url)` and reject malformed URLs. 2. Allow only the exact `http:` and `https:` schemes. 3. Resolve the hostname before connecting and reject every resolved address in loopback, private, link-local, multicast, unspecified, and reserved IPv4 and IPv6 ranges. 4. Prevent DNS rebinding by connecting only to a validated resolved address while preserving the intended host name for TLS and HTTP. 5. Revalidate the destination after every redirect and impose a low redirect limit. 6. Consider an allowlist of supported public platforms instead of allowing arbitrary generic websites. 7. Block cloud metadata destinations explicitly, including link-local metadata ranges. 8. Apply outbound firewall or sandbox rules so the Skill cannot reach internal networks even if application validation fails. 9. Add automated tests for loopback, private IPv4, IPv4-mapped IPv6, link-local IPv6, encoded IP addresses, alternate numeric IP forms, and DNS rebinding cases. ]]>
