other
- Location
plugin/vendor/kimi-code-sdk.mjs:288346- Finding
FetchURL Allows Internal-Network Requests Despite Its Public-Only Guarantee ## Remediation Suggestions 1. **Enforce destination restrictions before connecting.** Parse and normalize each URL, reject prohibited literal addresses, resolve hostnames, and reject non-public IPv4 and IPv6 destinations, including loopback, private, link-local, multicast, unspecified, and IPv4-mapped equivalents. 2. **Prevent DNS rebinding.** Bind connection establishment to the validated address using an appropriate resolver or connection dispatcher while preserving correct HTTP host handling and TLS verification. 3. **Validate every redirect.** Apply identical destination restrictions to each hop and fail closed on prohibited destinations. Preserve the existing redirect-count limit. 4. **Remove silent trust-boundary changes.** Disable unrestricted local fallback from remote fetching, or require an explicit administrator-controlled policy with the same destination protections. 5. **Add gateway egress controls.** Block access to internal networks and metadata services at the network layer unless explicitly required. 6. **Clarify approval semantics.** Document that manual mode and `approvalPolicy: "deny"` do not disable default-approved tools. Provide an explicit host-network capability control. 7. **Add regression tests.** Cover direct internal addresses, public-to-private redirects, IPv6, encoded address forms, DNS rebinding, and remote-provider fallback. Correct the tool description until its public-only guarantee is enforced.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/vendor/kimi-code-sdk.mjs, lines 288346–288405. Related tool execution: lines 277271–277325; provider selection: lines 288505–288538; native approval policy: lines 293650–293690 and 293890–293930.
Vulnerability Type: Server-Side Request Forgery (CWE-918)
Risk Level: HighVulnerable Code
The complete request-and-redirect method validates each URL but does not restrict its network destination:
js async requestWithRedirects(url2, signal) { let currentUrl = url2; let redirects = 0; for (; ; ) { validateFetchUrl(currentUrl); const response = await this.fetchImpl(currentUrl, { method: "GET", headers: { "User-Agent": this.userAgent }, signal, redirect: "manual" }); if (!REDIRECT_STATUSES.has(response.status)) return response; const location = response.headers.get("location"); if (location === null) return response; await response.body?.cancel().catch(() => { }); if (redirects >= MAX_REDIRECT_HOPS) throw new Error2( ErrorCodes$1.WEB_FETCH_FAILED, `Too many redirects while fetching "${url2}" (limit ${String(MAX_REDIRECT_HOPS)}).`, { details: { url: url2, limit: MAX_REDIRECT_HOPS } } ); redirects += 1; currentUrl = new URL(location, currentUrl).toString(); } }The complete destination validator only checks URL parsing and protocol:
js function validateFetchUrl(url2) { let parsed2; try { parsed2 = new URL(url2); } catch { throw new Error2( ErrorCodes$1.WEB_INVALID_URL, `Invalid URL: "${url2}"`, { details: { url: url2 } } ); } if (parsed2.protocol !== "http:" && parsed2.protocol !== "https:") throw new Error2( ErrorCodes$1.WEB_INVALID_URL, `Unsupported URL scheme "${parsed2.protocol}" \u2014 only http(s) allowed.`, { details: { url: url2, protocol: parsed2.protocol } } ); }Technical
...[truncated 2984 chars]
