fix(web): block private hosts in S3 endpoint test#1932
Open
richiemcilroy wants to merge 2 commits into
Open
Conversation
|
Paragon Review Skipped Hi @richiemcilroy! Your Polarity credit balance is insufficient to complete this review. Please visit https://app.paragon.run to finish your review. |
Member
Author
|
@greptileai please review the PR |
Member
Author
|
@greptileai please review the PR |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
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.
Blocks loopback, private, link-local and reserved hosts (including the cloud metadata IP and IPv6 literals) in the S3 endpoint connectivity test to prevent server-side request forgery.
Greptile Summary
This PR adds SSRF protection to the
/testS3 endpoint by blocking private, loopback, link-local, and reserved IP ranges before the S3 client is constructed, and closes the DNS-rebinding TOCTOU window by injecting aguardedLookupfunction into the HTTP agents that re-validates resolved addresses at connection time.expandIpv6to canonicalise IPv6 addresses — including IPv4-mapped (::ffff:) in both dotted-decimal and pure-hex form — andisBlockedIpwith correct bitmask checks for fe80::/10, fc00::/7, and loopback/unspecified ranges.AbortControllertimeout with per-agentconnectionTimeout/requestTimeout, and adds a 400 response for blocked endpoints before theS3Clientis ever instantiated.Confidence Score: 4/5
The SSRF protection is well-constructed and addresses the previously identified issues (fe80::/10 bitmask, ::ffff: hex form, DNS rebinding). One narrow gap remains in the IPv4-compatible IPv6 path that a determined attacker could express in a URL, though modern OS kernels don't route those addresses to IPv4 equivalents.
The dual-layer defence (pre-flight IP/hostname check + guardedLookup at connection time) is solid. The single remaining gap — IPv4-compatible IPv6 addresses with h[5]=0 — means an input like http://[::169.254.169.254] passes isBlockedIp, though practical exploitation requires OS support that modern Linux kernels don't provide.
apps/web/app/api/desktop/[...route]/s3Config.ts — specifically the isBlockedIp IPv6 branch where the IPv4-compatible (h[5]=0) case is not handled alongside the IPv4-mapped (h[5]=0xffff) case.
Important Files Changed
Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "fix(web): harden S3 endpoint SSRF guard ..." | Re-trigger Greptile