Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SMB2 compoud response signing #1834

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

jborean93
Copy link
Contributor

@jborean93 jborean93 commented Oct 11, 2024

Fix the signing the logic when responding with an SMB2 compount response. The signature will include the padding of each compound element and include the next offset value before signing the data.

The current logic was adding the signature but before it set the NextCommand entry and it did not include any of the padding added between each compound entry. By delaying the signing until after the compound entries are build we can ensure that the signatures are generated correctly so the client can verify them.

The padding data must be included in the signature as per MS-SMB2 https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/a3e9ea1e-53c8-4cff-94bd-d98fb20417c0

If the message is part of a compounded chain, any padding at the end of the message MUST be used in the hash computation

@jborean93 jborean93 force-pushed the smb2-compound-signing branch from c954e79 to 31806c1 Compare October 11, 2024 21:48
@gabrielg5 gabrielg5 self-assigned this Dec 12, 2024
@gabrielg5 gabrielg5 added the in review This issue or pull request is being analyzed label Dec 12, 2024
@gabrielg5
Copy link
Collaborator

gabrielg5 commented Jan 7, 2025

Hey @jborean93, thanks for all these PRs!

Reading the code changes for this one, seems aligned now with the documentation.
I have only one note related to the alignment of the last message in the compounded chain. Shouldn't it be padded to a multiple of 8b as well? Currently it is not being done (neither it wasn't previously)

Will do some tests on this branch before moving forward!

Update: Documentation answered my question... it's advised but not mandatory (3.3.4.1.3 Sending Compounded Responses)

The length of the last response in the compounded responses SHOULD be padded to a multiple of 8 bytes.

@jborean93
Copy link
Contributor Author

That's a good point, I'll update the code to always pad each compound message including the last one to align with the SHOULD in the docs.

Fix the signing the logic when responding with an SMB2 compount
response. The signature will include the padding of each compound
element and include the next offset value before signing the data.
@jborean93 jborean93 force-pushed the smb2-compound-signing branch from 31806c1 to ec41881 Compare January 7, 2025 18:25
@jborean93 jborean93 force-pushed the smb2-compound-signing branch from ec41881 to 1c5a202 Compare January 7, 2025 18:28
@gabrielg5
Copy link
Collaborator

Awesome!
Thank you!!

@gabrielg5 gabrielg5 merged commit 72648af into fortra:master Jan 8, 2025
8 checks passed
@jborean93 jborean93 deleted the smb2-compound-signing branch January 8, 2025 15:37
@jborean93
Copy link
Contributor Author

Thanks for the reviews on the various PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review This issue or pull request is being analyzed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants