Skip to content

Harden wildcard matching in HostMatcherPolicy. - #66582

Merged
halter73 merged 2 commits into
dotnet:mainfrom
cincuranet:dot-wildcard
May 13, 2026
Merged

halter73 merged 2 commits into
dotnet:mainfrom
cincuranet:dot-wildcard

Conversation

@cincuranet

Copy link
Copy Markdown
Contributor

Fixes #66581

Copilot AI review requested due to automatic review settings May 5, 2026 06:39
@cincuranet
cincuranet requested a review from halter73 as a code owner May 5, 2026 06:39
@github-actions github-actions Bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label May 5, 2026

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 RequireHost("*.example.com") wildcard matching in HostMatcherPolicy so it no longer matches invalid hosts that begin with a leading . (the “empty wildcard” case described in #66581).

Changes:

  • Added a leading-. rejection to suffix-wildcard host matching in HostMatcherPolicy.
  • Updated wildcard suffix extraction in EdgeKey to use the wildcard constant length.
  • Added integration tests asserting wildcard hosts do not match invalid leading-dot host values.

Reviewed changes

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

File Description
src/Http/Routing/src/Matching/HostMatcherPolicy.cs Rejects wildcard matches when the request host begins with . (and adjusts wildcard suffix extraction).
src/Http/Routing/test/UnitTests/Matching/HostMatcherPolicyIntegrationTestBase.cs Adds test coverage for invalid leading-dot host values with wildcard host metadata.

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

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RequireHost with wildcard matches "empty" subdomain

4 participants