fix : prevent DNS rebinding SSRF bypass in validateSafeUrl#2348
fix : prevent DNS rebinding SSRF bypass in validateSafeUrl#2348tmdeveloper007 wants to merge 1 commit into
Conversation
|
Someone is attempting to deploy a commit to the Nisshchaya's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 41 minutes and 3 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎉 Thanks for your contribution, @tmdeveloper007!Your PR has passed our automated GSSoC quality checks. Here's a quick summary:
A maintainer will review your PR soon. Please be patient and available for feedback. 💪 GSSoC'26 automation · Maintainer: @nisshchayarathi |
Fixes #2083
Summary
The
validateSafeUrlfunction inlib/utils/ssrfValidator.tsuseddns.lookup(), which delegates to the system resolver (respecting/etc/hostsand nsswitch.conf). This created a DNS rebinding window: an attacker could control what IP the system resolver returns independently of actual DNS records.Changes
lib/utils/ssrfValidator.ts: Replaceddns.lookup()with directdns.resolve4()/dns.resolve6()calls. Changed return type fromPromise<boolean>toPromise<UrlValidationResult>to include the validated public IP.lib/services/imageService.ts: UpdatedfetchAndValidateAvatarUrlto use the validated IP directly in the fetch URL with the original hostname preserved in theHostheader, preventing DNS rebinding at fetch time.lib/services/securitySandboxService.ts: UpdatedbuildSandboxImageto accept the validated IP and configure git withurl.<base>.insteadOfto clone using the IP directly, preventing DNS rebinding during git operations.app/api/repositories/route.ts: Updated to use the newUrlValidationResultreturn type.Security Impact
Closes the DNS rebinding window where an attacker could make a domain resolve to a public IP during validation but a private IP when the actual HTTP request or git clone is made.