Skip to content

range-check the port for IPv6 hosts in isValidAuthority#412

Merged
sebbASF merged 1 commit into
apache:masterfrom
sahvx655-wq:ipv6-port-range
Jun 25, 2026
Merged

range-check the port for IPv6 hosts in isValidAuthority#412
sebbASF merged 1 commit into
apache:masterfrom
sahvx655-wq:ipv6-port-range

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

IPv6 host port skips the range check in isValidAuthority

The port group in AUTHORITY_PATTERN is captured the same way for a bracketed IPv6 host as for a hostname or IPv4 host, but the 0 to 65535 range check only ran in the hostname/IPv4 branch of isValidAuthority. That left a gap: http://[::1]:99999/ and http://[::1]:65536/ validated as good while the equivalent http://127.0.0.1:99999/ and http://example.com:99999/ were correctly rejected, so an out-of-range port slipped through purely on the strength of the host being IPv6.

Moved the existing port parse and range check out of that branch so both host forms are checked the same way. Valid ports such as [::1]:65535 and [::1]:80, and the no-port case, are unaffected. Added a regression test that fails without the change.

@sebbASF sebbASF merged commit 0eef078 into apache:master Jun 25, 2026
10 checks passed
@sebbASF

sebbASF commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants