Skip to content

HDDS-15776. Make S3 Gateway VirtualHostStyleFilter IPv6-safe#10809

Open
rich7420 wants to merge 1 commit into
apache:masterfrom
rich7420:HDDS-15776
Open

HDDS-15776. Make S3 Gateway VirtualHostStyleFilter IPv6-safe#10809
rich7420 wants to merge 1 commit into
apache:masterfrom
rich7420:HDDS-15776

Conversation

@rich7420

@rich7420 rich7420 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

VirtualHostStyleFilter.checkHostWithoutPort() stripped the port from the
Host header with host.lastIndexOf(':'). That mangles IPv6 literals, because
their address segments also contain colons:

  • [::1]:9878 / [2001:db8::1]:9878 — the address itself gets truncated
  • a bare 2001:db8::1 — the last address segment is mistaken for a port

As a result an S3 Gateway reachable on an IPv6 address rejects otherwise valid
requests when a domain is configured.

This change parses the host with Guava HostAndPort.fromString(host).getHost(),
which is bracket-aware: [::1]:9878 and [::1] both yield ::1, and a bare
2001:db8::1 is returned unchanged. This matches how HddsUtils already parses
host/port elsewhere. A malformed Host value (for example an unbalanced
bracket) falls back to the raw value, so it is rejected with the existing
"no matching domain" error rather than failing with an internal error.

Part of the IPv6 support epic HDDS-15763.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15776

How was this patch tested?

mvn -pl :ozone-s3gateway test -Dtest=TestVirtualHostStyleFilter

https://github.com/rich7420/ozone/actions/runs/29688355419

checkHostWithoutPort used host.lastIndexOf(':') to strip the port, which
mangles IPv6 literals (e.g. [2001:db8::1] or a bare 2001:db8::1). Use Guava
HostAndPort.fromString(host).getHost() for bracket-aware host/port separation,
matching HddsUtils. Add tests for hostname/IPv4/IPv6 Host headers with and
without a port, plus a malformed-host fallback.
Copilot AI review requested due to automatic review settings July 19, 2026 13:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jojochuang
jojochuang requested review from jojochuang and smengcl July 20, 2026 16:20
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