Skip to content

Fix CodeQL password-hash warnings in the SSO samples - #6097

Draft
Eugene (OEvgeny) wants to merge 2 commits into
mainfrom
OEvgeny/fix-codeql-sso-samples-hash
Draft

Eugene (OEvgeny) wants to merge 2 commits into
mainfrom
OEvgeny/fix-codeql-sso-samples-hash

Conversation

@OEvgeny

@OEvgeny Eugene (OEvgeny) commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes CodeQL js/insufficient-password-hash warnings in the SSO samples under samples/07.advanced-web-chat-apps.

Changelog Entry

Fixed

  • 🏫 Fixed SSO samples deriving the PKCE verifier and OAuth state with a fast hash, in PR #6097, by @OEvgeny

Description

The SSO samples derived the PKCE code verifier and the GitHub OAuth state from a seed and a salt with SHA-512/SHA-384, a fast hash that CodeQL flags. They now use Node's built-in crypto.scryptSync, a KDF that the rule recommends. The js/weak-hashes warning on __tests__/setup/NUnitTestReporter.js needs no change: #5416 removed that file.

Design

  • scrypt is deterministic, so every server still derives the same value from the same seed and salt. Cost is explicit (N: 16384), about 25 ms per call.
  • PBKDF2 also satisfies the rule; scrypt needs no iteration count.

Specific Changes

  • createPKCECodeVerifier.js (b, c, d, e): 64 scrypt bytes as base64url (86 characters); the old encoder left a trailing =, which RFC 7636 does not allow.
  • generateOAuthState.js (b, c, d, e): 5 scrypt bytes, still 10 hex characters.
Verification (b shown; c, d, e the same)
PKCE  verifier 86 chars ✓ deterministic ✓ seeds differ ✓ RFC 7636 ✓ S256 challenge 43 chars ✓ (28.1 ms)
STATE "30d39c1575" ✓ deterministic ✓ seeds differ ✓ salts differ ✓ 10 hex ✓ (31.0 ms)
  • I have added tests and executed them locally
  • I have added .changelog/<PR#>-<slug>.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

Eugene Olonov added 2 commits December 3, 2026 11:16
CodeQL js/insufficient-password-hash flagged the SSO samples under
07.advanced-web-chat-apps for deriving the PKCE code verifier and the GitHub
OAuth "state" from a seed and a salt with a fast hash (SHA-512 / SHA-384).

Derive them with crypto.scryptSync (N: 16384) instead. scrypt is deterministic
for the same seed and salt, so any server instance still recomputes the same
verifier or state, as the samples' distributed design requires.

- createPKCECodeVerifier.js (b, c, d, e): 64 bytes, encoded with Node's
  base64url (86 characters). The previous encoder left a trailing "=", which
  is outside the RFC 7636 verifier alphabet.
- generateOAuthState.js (b, c, d, e): 5 bytes as hex, still 10 characters.
  c, d and e carry identical copies of this helper, changed the same way.

createPKCECodeChallenge.js (SHA-256 of the verifier, required by S256) is
unchanged.

This branch has not been deployed

No deployments
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