-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(core): randomize code verifier length for PKCE flow #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughWhen Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/core/src/secure.ts`:
- Around line 25-29: The code uses generateSecure(byteCount) but validates
characters, causing oversized verifiers; change the random byte length selection
so it produces 43–128 base64url characters by selecting 32–96 bytes (since
ceil(bytes*4/3) yields 43–128 chars). Concretely, replace the current length
calculation (Math.random() * (128 - 43 + 1) + 43) with a random byte count
between 32 and 96 and call generateSecure(byteCount) to produce codeVerifier,
keeping the existing codeVerifier length check and AuthSecurityError unchanged;
reference generateSecure, length, codeVerifier, and AuthSecurityError when
making the change.
Description
This pull request introduces randomization of the PKCE code verifier length using the
createPKCEfunction. With this change, thecode_verifierlength varies on each request, using a randomized length between 42 and 128 characters, as defined by the PKCE RFC specification.This improves security by avoiding predictable verifier lengths while remaining fully compliant with the PKCE standard.
Resources
Summary by CodeRabbit