Conversation
The Code-node sandbox fetch wrapper checked the SSRF blocklist only on the initial URL, then let undici follow 3xx redirects transparently. A redirect from a public attacker host could chase a 302 into IMDS (169.254.169.254), the K8s apiserver, or *.svc.cluster.local and return the response to the sandbox. Follow redirects manually with redirect:"manual", re-running the scheme and SSRF checks on each Location before issuing the next request, capped at 20 hops with POST->GET body downgrade matching undici's follow semantics. This mirrors the per-hop validation lib/safe-fetch.ts already performs via its undici connector.
The redirect test server reflected a request query param into the Location header, which CodeQL flags as a server-side open redirect. Key a fixed, server-defined target table by request path instead so no request data reaches the redirect target. Behaviour is unchanged.
…-ssrf-revalidation fix(sandbox): re-validate SSRF on every redirect hop in sandboxed fetch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.