fix: echo server TargetInfo in NTLMv2 AUTHENTICATE to fix STATUS_LOGON_FAILURE#2
Open
nima-sayadi wants to merge 1 commit into
Open
Conversation
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
NTLMv2 authentication fails against real SMB servers even with correct
credentials, returning
STATUS_LOGON_FAILURE (0xC000006D)during session setup.This affects Windows 10/11 and Samba-based NAS (e.g. AVM FritzBox).
Root cause
decodeChallengeMessagereturned only the 8-byte server challenge and threwaway the server's
TargetInfo(AV_PAIR list) from the CHALLENGE.encodeAuthenticationMessagetherefore fabricated its ownTargetInfofrom the client hostname/domain. Per MS-NLMP, the NTLMv2
NTProofStris anHMAC over (among other things) the server's
TargetInfo, so a fabricated onemakes the proof mismatch and the server rejects the logon.
negotiateFlags = 0(strippingUnicode / extended session security) and, for unqualified users, hashed with
an empty/guessed domain.
Fix
decodeChallengeMessagenow returns the full challenge: server challenge,raw
TargetInfo, target name, and the parsed domain/timestamp.encodeAuthenticationMessageechoes the server'sTargetInfoverbatim,derives the domain from the challenge when the caller supplies none, prefers
the server-supplied timestamp, and advertises correct negotiate flags.
createNtlmV2Responseincludes the trailing reserved field so the blob isbyte-exact per MS-NLMP.
console.loghandshake noise.Testing
Added
test/ntlm.test.ts(run withnpm test) validating against the officialMS-NLMP 4.2.4 test vectors:
NTProofStr(68cd0ab8…)Verified end-to-end against a live FritzBox SMB share (previously failing with
STATUS_LOGON_FAILURE, now authenticates and performs file operations).Notes
decodeChallengeMessagenow returns an object instead of aBuffer. The onlyin-repo caller (
Session) is updated; external callers using it directly wouldneed to read
.serverChallenge.