Repository navigation
Accept RFC-compliant Bearer schemes (case-insensitive, 1*SP) - #340
Merged
Merged
Conversation
extract_bearer compared Authorization to a literal "Bearer " prefix. RFC 9110 makes the auth-scheme case-insensitive and RFC 6750 uses 1*SP between scheme and token, so bearer/BEARER and extra spaces 401'd valid tokens. Parse via parse_bearer_authorization and trim trailing OWS so a proxy-appended space is not hashed into the token. Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
Keep both Unreleased changelog entries. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_e3394a32-7f16-4fe3-857c-f6eb486d6a1e) |
Keep both Unreleased changelog entries. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep both Unreleased changelog entries. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Problem
extract_bearercompared the Authorization field to a literal"Bearer "prefix. RFC 9110 makes the auth-scheme case-insensitive; RFC 6750 is"Bearer" 1*SP token68. Clients that sendbearer,BEARER, or extra spaces after the scheme got 401 for a valid token. Two spaces also left a leading space on the token, so the SHA-256 lookup missed.Fix
parse_bearer_authorizationmatchesbearercase-insensitively, skips one or more spaces, and trims trailing OWS so a proxy-appended space is not hashed into the token.extract_beareris the header-map lookup.Tabs after the scheme still reject (RFC
1*SP, not HTAB). Other schemes (Basic, …) still reject.Tests
unit_auth— canonical Bearer, case folding, extra spaces, trailing OWS, malformed/non-Bearer. 5/5 locally (+ ASan/UBSan).Independently mergeable against
main(0456350). Code hunks (auth.cpp,http_util.{h,cpp}, newtest_auth.cpp, CMake unit target afterunit_sse_mailbox) do not overlap #321–#339.git merge-tree --write-treeauto-merges those siblings; CHANGELOG[Unreleased]is the usual sibling note.Note
Medium Risk
Changes authentication header parsing for all
/v1/*bearer checks; behavior is broader (more inputs accepted) but aligned with standards and covered by new unit tests.Overview
Bearer
Authorizationparsing now follows RFC 6750 / RFC 9110 instead of requiring an exactBearerprefix.A new
parse_bearer_authorizationinhttp_utiltreats the scheme case-insensitively (bearer,BEARER, etc.), skips one or more spaces after it, and trims trailing OWS so extra spaces do not end up in the token hash.extract_beareronly looks up the header and delegates to that helper.Adds
unit_authdoctest coverage for canonical Bearer, case folding, spacing, trailing whitespace, and malformed/non-Bearer values, plus a changelog [Unreleased] note.Reviewed by Cursor Bugbot for commit 5e54fc2. Bugbot is set up for automated code reviews on this repo. Configure here.