Skip to content

114 use crypto.randomBytes for NTLMv2 client challenge - #115

Open
shtief wants to merge 1 commit into
SamDecrock:masterfrom
shtief:fix-114-csprng-nonce
Open

shtief wants to merge 1 commit into
SamDecrock:masterfrom
shtief:fix-114-csprng-nonce

Conversation

@shtief

@shtief shtief commented Sep 17, 2026

Copy link
Copy Markdown

What

Replaces the Math.random()-based byte-building loop in createType3Message() with crypto.randomBytes(8) for generating the NTLMv2 client challenge nonce.

Why

Math.random() is not a CSPRNG and its output is predictable, weakening the protocol's protection against replay/relay attacks (see #114).

How

crypto is already required in ntlm.js (used elsewhere for MD5/HMAC), so this is a drop-in replacement:

var clientChallengeBytes = crypto.randomBytes(8);

This removes the manual loop and the Buffer.from(..., 'ascii') step entirely.

Closes #114

- Replace Math.random()-based byte loop with crypto.randomBytes(8)
- Fixes predictable nonce generation flagged in issue SamDecrock#114
shtief added a commit to ClarkSource/node-http-ntlm that referenced this pull request Sep 17, 2026
- Apply upstream PR SamDecrock#115 (SamDecrock/node-http-ntlm): replace weak
  Math.random() NTLMv2 client-challenge nonce with crypto.randomBytes(8)
- Update unit tests to mock crypto.randomBytes instead of Math.random
  for deterministic NTLMv2 client-challenge assertions
- Bump underscore dependency from ~1.12.1 to ^1.13.8
  (GHSA-qpx9-hpmf-5gmw, unbounded recursion/DoS)
- Rename package to @clark/httpntlm, bump version to 1.9.0
- Point bugs/repository URLs at the ClarkSource fork
- Update README install/usage snippets to the new package name
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.

createType3Message() uses Math.random() for the NTLMv2 client challenge nonce, not a CSPRNG

1 participant