Skip to content

fix: complete patch for GHSA-mvf2-f6gm-w987 and #586#598

Merged
SociableSteve merged 3 commits intonearform:masterfrom
dcs-soni:fix-jwt-algorithm-confusion
Apr 7, 2026
Merged

fix: complete patch for GHSA-mvf2-f6gm-w987 and #586#598
SociableSteve merged 3 commits intonearform:masterfrom
dcs-soni:fix-jwt-algorithm-confusion

Conversation

@dcs-soni
Copy link
Copy Markdown
Contributor

@dcs-soni dcs-soni commented Apr 7, 2026

This branch builds directly on the initial work started by @antoatta85 in #586, but incorporates the missing code review feedback raised by @FlowmasterHaggla.

  • Replaced key with trimmedKey when calling ECPrivateKey.decode and PrivateKey.decode in src/crypto.js to ensure EC/PKCS8 private keys with whitespace do not crash the parser.
  • Refactored test/crypto.spec.js to use a leadingWhitespacePrefixes array, testing multiple combinations (\n, spaces, tabs, and mixed \n ) to mathematically guarantee the .trim() logic cannot be bypassed by any whitespace permutation.

Fixes #589

Copy link
Copy Markdown
Contributor

@SociableSteve SociableSteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor change to get this ready.

Comment thread test/crypto.spec.js
}
})

test('detectPublicKeyAlgorithms - EC public key with leading whitespace must be detected as EC (not HMAC)', t => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate of the test above it. We can probably remove it.

@SociableSteve
Copy link
Copy Markdown
Contributor

Hi 👋 Thanks for this PR. FYI there are 3 open CVEs against this repo at the moment and we are actively working to get through them as expeditiously as possible.

@dcs-soni
Copy link
Copy Markdown
Contributor Author

dcs-soni commented Apr 7, 2026

A minor change to get this ready.

Oh yes! Done. Good catch on the duplicate test.

@dcs-soni dcs-soni requested a review from SociableSteve April 7, 2026 11:07
@SociableSteve SociableSteve merged commit 597c4b6 into nearform:master Apr 7, 2026
7 checks passed
@dcs-soni dcs-soni deleted the fix-jwt-algorithm-confusion branch April 7, 2026 12:54
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.

Address Sec Adv: Whitespace-Prefixed RSA Key

3 participants