Skip to content

fix(middleware): check Basic auth scheme boundary in v4 - #3188

Merged
vishr merged 1 commit into
v4from
fix/v4-basic-auth-scheme-boundary
Oct 22, 2026
Merged

vishr merged 1 commit into
v4from
fix/v4-basic-auth-scheme-boundary

Conversation

@vishr

@vishr vishr commented Oct 22, 2026

Copy link
Copy Markdown
Member

Backport of #3138 by @Shubham-Padkonde to v4.

BasicX followed 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.ServeHTTP and asserts HTTP 401, the authentication challenge, and that the credential validator is not invoked. v4 reads only the first Authorization header and has no AllowedCheckLimit, 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 and git diff --check pass afterward. No API or dependency changes.

Original contributor credit is preserved in the commit trailer.

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]>
@vishr
vishr merged commit 6d1bb2e into v4 Oct 22, 2026
8 checks passed
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.

1 participant