Repository navigation
fix(middleware): check Basic auth scheme boundary in v4 - #3188
Merged
Merged
Conversation
Backport #3138. Reject malformed schemes such as BasicX before decoding credentials or invoking the validator. v4 reads only its first Authorization header and has no AllowedCheckLimit, so its regression covers that API. Co-authored-by: Shubham Padkonde <[email protected]>
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.
Backport of #3138 by @Shubham-Padkonde to v4.
BasicXfollowed by valid encoded credentials currently reaches the protected handler because v4 checks only the first five characters and skips the next character without validating the separator. Require a space after the case-insensitive Basic scheme. Valid credentials are still required; this is a parsing correction.The v4 regression sends the malformed header through
Echo.ServeHTTPand asserts HTTP 401, the authentication challenge, and that the credential validator is not invoked. v4 reads only the first Authorization header and has noAllowedCheckLimit, so the v5 check-limit case does not apply.Validation on macOS / Go 1.27.3: the new regression fails before the production change;
go test -race ./...,go vet ./..., formatting andgit diff --checkpass afterward. No API or dependency changes.Original contributor credit is preserved in the commit trailer.