Fix DNS rebinding bypass (#69)#73
Draft
jjk1492 wants to merge 1 commit into
Draft
Conversation
Hostnames that resolve to RFC-1918/loopback addresses (e.g. evil.com → 127.0.0.1) previously bypassed local_filter because the regex only matched literal IPs. After the regex check, resolve the hostname and reject any address that falls in a private range. Reuses the existing dns permission and browser.dns.resolve() call. Closes ACK-J#69 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Problem
The
local_filterregex incancel()only matches requests whose URL contains a literal local IP address orlocalhost. A hostname likeattacker.comthat resolves to127.0.0.1passes all checks unblocked:thirdParty: true— passes same-origin guardlocal_filterregex — no match (URL contains the hostname, not the IP)Reported in #69.
Fix
Added a pure
isPrivateIPv4(ip)helper that covers all RFC-1918, loopback (127.0.0.0/8), link-local (169.254.0.0/16), and 0.0.0.0 ranges.Updated the DNS resolution block to call
browser.dns.resolve()once and check both:The existing
dnspermission andbrowser.dns.resolve()usage are unchanged. Thelocal_filterregex is kept as a fast pre-filter for literal-IP URLs.Fail-open on DNS error — resolution failures (NXDOMAIN, captive portals, split-horizon DNS) allow the request through rather than breaking legitimate browsing.
Testing
Load the extension from source, open the browser console, and verify a domain with an A record pointing to 127.0.0.1 is blocked while a non-local domain is allowed.
Closes #69