Skip to content

Harden wildcard matching with empty segments inside - #67757

Merged
cincuranet merged 1 commit into
dotnet:mainfrom
cincuranet:fix-empty-host
Jul 20, 2026
Merged

cincuranet merged 1 commit into
dotnet:mainfrom
cincuranet:fix-empty-host

Conversation

@cincuranet

Copy link
Copy Markdown
Contributor

Fixes #67756

Copilot AI review requested due to automatic review settings July 13, 2026 12:23

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 pull request hardens host wildcard matching to reject hosts containing empty DNS labels (consecutive dots) within the hostname, addressing issue #67756 (e.g., foo..example.com, foo..bar.example.com).

Changes:

  • Updated HostMatcherPolicy wildcard host matching to reject request hosts that contain consecutive dots (..).
  • Updated HostString.MatchesAny wildcard matching to also reject hosts containing consecutive dots.
  • Added test coverage for foo..example.com and foo..bar.example.com in both Routing integration tests and HostString unit tests.

Reviewed changes

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

File Description
src/Http/Routing/test/UnitTests/Matching/HostMatcherPolicyIntegrationTestBase.cs Adds integration test cases ensuring wildcard host matching rejects hosts with empty labels inside (..).
src/Http/Routing/src/Matching/HostMatcherPolicy.cs Adds .. rejection logic for wildcard host matching in both runtime matching paths.
src/Http/Http.Abstractions/test/HostStringTest.cs Adds unit test cases ensuring HostString.MatchesAny rejects wildcard matches with empty labels inside.
src/Http/Http.Abstractions/src/HostString.cs Adds .. rejection logic for subdomain wildcard matching in MatchesAny.

@cincuranet
cincuranet merged commit 70e4f65 into dotnet:main Jul 20, 2026
27 checks passed
@cincuranet
cincuranet deleted the fix-empty-host branch July 20, 2026 06:44
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 21, 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.

Harden wildcard matching with empty segments inside

3 participants