Repository navigation
smbclient: verify the final SESSION_SETUP response signature - #5326
Open
musthaf-bughunter wants to merge 1 commit into
Open
musthaf-bughunter wants to merge 1 commit into
musthaf-bughunter wants to merge 1 commit into
Conversation
SMB_Client derives the signing key in AUTHENTICATED, after the final SESSION_SETUP response went through SMBStreamSocket.recv, so the signature of that response was never checked ([MS-SMB2] 3.2.5.3.1). A man-in-the-middle could clear SMB2_SESSION_FLAG_ENCRYPT_DATA and the client then sent its next requests unencrypted. Verify the response once the keys are computed, for non-guest sessions. AI-Assisted: yes (Claude Opus 5.5)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5326 +/- ##
==========================================
+ Coverage 81.12% 81.15% +0.02%
==========================================
Files 376 376
Lines 99524 99530 +6
==========================================
+ Hits 80743 80770 +27
+ Misses 18781 18760 -21
🚀 New features to boost your workflow:
|
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.
Description
SMBStreamSocket.recvonly verifies signatures oncesession.SigningKeyis set (smb2.py#L3846), butSMB_Clientderives the keys inAUTHENTICATED(smbclient.py#L651), after the final SESSION_SETUP response was received. Its signature is therefore never checked, contrary to [MS-SMB2] 3.2.5.3.1 / 3.2.5.1.3.A man-in-the-middle can clear
SMB2_SESSION_FLAG_ENCRYPT_DATAin that response: against a server withREQUIRE_ENCRYPTION=True(SMB 3.0, 3.0.2, 3.1.1), the client keepsEncryptData=Falseand sends its next requests (TREE_CONNECT, ...) in plaintext. The added test relays the exchange betweenSMB_ServerandSMB_Clientover socketpairs and clears the flag; it fails on master withtampered SESSION_SETUP response was accepted.The response is now verified in
AUTHENTICATEDfor non-guest sessions when signing is required or the dialect is 3.1.1.SMB2_Header.verifyraisesScapy_Exceptioninstead ofExceptionso the failure can be caught.