Improve DNS rebinding fix with IPv6 private range checks#77
Merged
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 #69 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extend PR #73's DNS-resolved address validation to cover IPv6 loopback, link-local, and ULA ranges, plus IPv4-mapped IPv6 addresses. Extract isPrivateAddress() into global/privateAddress.js and return early when the request URL cannot be parsed before calling browser.dns.resolve(). Co-authored-by: Hacks and Hops <ACK-J@users.noreply.github.com>
Use isLocalRequestUrl() to detect local/private targets via the URL API and isPrivateAddress() instead of matching raw URL strings with a large regex. This correctly rejects localhost.example.com, handles IPv6 literals, and normalizes hostname edge cases like trailing dots and octal IPv4 forms. Co-authored-by: Hacks and Hops <ACK-J@users.noreply.github.com>
Pass url.hostname (not url.host) to browser.dns.resolve() so URLs with ports are checked correctly. Skip DNS for public IP literals since isLocalRequestUrl() already handles private literals. Extract blockPortScan() to deduplicate the port-scan block path. Co-authored-by: Hacks and Hops <ACK-J@users.noreply.github.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.
Builds on #73 to close the DNS rebinding bypass (#69).
Changes
local_filterregex with URL parsing —isLocalRequestUrl()uses the URL API andglobal/privateAddress.jsinstead of regex-matching raw URL strings.browser.dns.resolve()and block when any address is private.::1), link-local (fe80::/10), ULA (fc00::/7), IPv4-mapped private addresses.localhostmatching (excludeslocalhost.example.com), trailing-dot FQDN normalization, browser-normalized IPv4 forms.url.hostnamefor DNS — useurl.hostname(noturl.host) so URLs with ports likehttp://example.com:8080resolve correctly.isLocalRequestUrl().Review fixes (latest)
browser.dns.resolve(url.host)included port, causing fail-openurl.hostnamehttp://8.8.8.8blockPortScan()helperBehavior improvements over old regex
http://localhost.example.comhttp://[::1]:8080http://localtest.me(DNS→127.0.0.1)http://rebinding.local:8080via/etc/hosts→192.168.1.1Testing
Closes #69. Supersedes #73.