Skip to content

ntlm: check the NTProofStr in NTLMSSP._getSessionBaseKey - #5303

Open
musthaf-bughunter wants to merge 1 commit into
secdev:masterfrom
musthaf-bughunter:ntlm-check-ntproofstr
Open

musthaf-bughunter wants to merge 1 commit into
secdev:masterfrom
musthaf-bughunter:ntlm-check-ntproofstr

Conversation

@musthaf-bughunter

Copy link
Copy Markdown
Contributor

Description

NTLMSSP._getSessionBaseKey derives the session key from the client's NTProofStr without checking it (ntlm.py#L2146-L2156); the check only happens later in _checkLogin. NTLMSSP_DOMAIN._checkLogin always returns True (#L2380-L2382), but NTLMSSP_DOMAIN._getSessionBaseKey falls back to the parent for local IDENTITIES when the AUTHENTICATE message has no DomainName (#L2279-L2281) or when Netlogon fails. An NTLMSSP_DOMAIN acceptor configured with IDENTITIES therefore accepts any password for those users.

Repro (client sends an empty DomainName and no MIC):

dom = NTLMSSP_DOMAIN(UPN="SRV1$@domain.local", HASHNT=b"\x11" * 16,
                     IDENTITIES={"User1": MD4le("Password1")})
# NTLM login as User1 with password "WrongPassword"  -> GSS_S_COMPLETE

The NTProofStr is now checked in _getSessionBaseKey, and a mismatch returns None, which the caller already handles as "Bad NTProofStr or unknown user" (#L1993-L1996). For plain NTLMSSP, a wrong password now returns GSS_S_DEFECTIVE_CREDENTIAL instead of falling through and returning None. A test for both SSPs is added to ntlm.uts.

_getSessionBaseKey derived the session key from the client NTProofStr
without checking it, relying on _checkLogin. NTLMSSP_DOMAIN overrides
_checkLogin to return True and falls back to the parent
_getSessionBaseKey for local IDENTITIES, so any password was accepted
for those users. Check the NTProofStr where the key is derived.

AI-Assisted: yes (Claude Opus 5.5)
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.68%. Comparing base (787e73f) to head (a8154a3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5303      +/-   ##
==========================================
+ Coverage   80.65%   80.68%   +0.02%     
==========================================
  Files         375      375              
  Lines       98785    98789       +4     
==========================================
+ Hits        79679    79707      +28     
+ Misses      19106    19082      -24     
Files with missing lines Coverage Δ
scapy/layers/ntlm.py 84.41% <100.00%> (+3.86%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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