Repository navigation
fix(broker): match service hosts case-insensitively - #461
Open
RaphaelFakhri wants to merge 2 commits into
Open
RaphaelFakhri wants to merge 2 commits into
RaphaelFakhri wants to merge 2 commits into
Conversation
|
✅ CLA satisfied. All contributors have signed the current CLA. The |
Contributor
[Medium impact] The PR appears safe to merge; the earlier credential-leak finding is fixed and no new actionable issues were found.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
matchHostPatterncompared the request host with the service host pattern byte for byte. DNS names are case-insensitive (RFC 4343), so a request toAPI.Stripe.commissed a service configured forapi.stripe.com. The request then got no credential injection and fell through to the unmatched-host policy. The reverse also failed:ValidateHostaccepts uppercase letters, so a service saved asAPI.Stripe.comnever matched clients that lowercase the host, such as Node.js and Python urllib3.This change lowercases both the pattern and the host before comparing them. The fix covers exact and
*.wildcard patterns, andAnyHostMatches, which uses the same helper.Type of change
Test plan
make test)TestMatchServiceHostCaseInsensitivecovers mixed-case hosts against an exact pattern and a mixed-case wildcard pattern, and checksAnyHostMatches. It fails without the fix (host "API.Stripe.COM": expected stripe, got <nil>) and passes with it.go test ./internal/broker/ ./internal/proposal/,go vet ./internal/broker/andgofmt -lare clean.Security checklist
Fixes #460