Skip to content

Harden host filtering middleware matching leading dot when using wildcard - #67265

Merged
cincuranet merged 6 commits into
dotnet:mainfrom
cincuranet:hostfilterdot
Jun 22, 2026
Merged

Harden host filtering middleware matching leading dot when using wildcard#67265
cincuranet merged 6 commits into
dotnet:mainfrom
cincuranet:hostfilterdot

Conversation

@cincuranet

@cincuranet cincuranet commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #66652. Related to #66582.

@cincuranet
cincuranet marked this pull request as ready for review June 18, 2026 12:49
Copilot AI review requested due to automatic review settings June 18, 2026 12:49

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.

Pull request overview

This PR hardens wildcard host matching in HostString.MatchesAny to prevent *.example.com-style patterns from accepting hosts that begin with a dot (e.g., ..example.com), addressing the host filtering bypass described in #66652.

Changes:

  • Tighten subdomain wildcard matching to require the host not start with . when matching *. patterns.
  • Add a regression test ensuring ..example.com:443 does not match *.example.com.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Http/Http.Abstractions/src/HostString.cs Adds an additional condition to block wildcard matches when the host begins with ..
src/Http/Http.Abstractions/test/HostStringTest.cs Adds a regression case to ensure ..example.com:443 does not match *.example.com.

@cincuranet
cincuranet merged commit 51a99f3 into dotnet:main Jun 22, 2026
25 checks passed
@cincuranet
cincuranet deleted the hostfilterdot branch June 22, 2026 07:40
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 23, 2026
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.

HostFiltering middleware improperly matches hosts with leading dot

3 participants