Repository navigation
fix(auth-oauth2): use crypto.randomBytes for implicit grant OIDC nonce - #855
Open
samuel-conner wants to merge 1 commit into
Open
samuel-conner wants to merge 1 commit into
samuel-conner wants to merge 1 commit into
Conversation
plugins/auth-oauth2/src/grants/implicit.ts generated the OIDC id_token replay-protection nonce using Math.random() (CWE-338), while sibling grants in the same plugin (authorizationCode.ts, clientCredentials.ts) already use node:crypto.
Switch to randomBytes(16).toString('hex') from node:crypto and add unit tests in plugins/auth-oauth2/tests/implicit.test.ts.
Signed-off-by: Samuel Conner <49850235+samuel-conner@users.noreply.github.com>
|
Thanks for the PR. This appears to match Yaak's contribution policy and is awaiting review by @gschier. This only means the PR is in scope for review. It does not mean the change has been reviewed or accepted for merge. |
[Medium impact] This PR appears safe to merge. SummaryReplaces
Reviews (1) · Last reviewed commit: "fix(auth-oauth2): use crypto.randomBytes..." · Reviewed by Greptile |
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
plugins/auth-oauth2/src/grants/implicit.tsgenerated the OIDCid_tokenreplay-protectionnoncequery parameter usingMath.random()(non-cryptographic PRNG, CWE-338), whereas sibling grants in@yaak/auth-oauth2(authorizationCode.tsPKCE verifier andclientCredentials.tsjti) already usenode:crypto.This replaces
String(Math.floor(Math.random() * 9999999999999) + 1)withrandomBytes(16).toString("hex")fromnode:crypto(128-bit CSPRNG hex string) and adds unit tests inplugins/auth-oauth2/tests/implicit.test.ts.Verified locally:
vp test --run plugins/auth-oauth2/tests: 7/7 test files, 56/56 tests passed (including 2 new tests inimplicit.test.ts).vp lint&vp fmt --check: 0 warnings, 0 errors.Submission
CONTRIBUTING.md.Explicit permission feedback item (required if not a bug fix):
N/A (bug fix)
Related
Found & verified offline with CipherMap (zero-telemetry static scanner) — happy to adjust or add tests if preferred. Contact: Samuel Conner (sam@ciphermap.io · https://www.ciphermap.io/verify).