Skip to content

fix(request): do not split bracketed IPv6 hosts into subdomains - #7536

Closed
princejain756 wants to merge 1 commit into
expressjs:masterfrom
princejain756:fix-subdomains-ipv6
Closed

princejain756 wants to merge 1 commit into
expressjs:masterfrom
princejain756:fix-subdomains-ipv6

Conversation

@princejain756

Copy link
Copy Markdown

req.subdomains split an IPv6 host containing dots. req.hostname keeps the brackets of an IPv6 literal ([::ffff:127.0.0.1]), and net.isIP() rejects the bracketed form, so the address was treated as a domain name and dot-split:

Host: [::ffff:127.0.0.1]  ->  ["0", "[::ffff:127"]   (was)
Host: [::ffff:127.0.0.1]  ->  []                     (now, same as [::1])
offset 0                  ->  ["[::ffff:127.0.0.1]"] (now)

isIP now runs on the unbracketed address; the returned subdomains still report the host as written. [::1] and IPv4 behavior unchanged (13 subdomains tests + full suite green).

Fixes #7532

req.hostname keeps the brackets of an IPv6 literal such as
[::ffff:127.0.0.1], and net.isIP rejects the bracketed form, so
req.subdomains dot-split the address into bogus parts like
["0", "[::ffff:127"]. The isIP check now runs on the unbracketed
address; the subdomains value still reports the host as written.

Fixes expressjs#7532
@krzysdz

krzysdz commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Duplicate of #7533

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

req.subdomains splits an IPv6 host that contains dots

2 participants