-
Notifications
You must be signed in to change notification settings - Fork 27
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 offset calculation for the MIC field to match the specification #64
Conversation
In most cases the change is bening because NTLMSSP_NEGOTIATE_VERSION is sent by the server in CHALLENGE_MESSAGE and then repeated in AUTHENTICATION_MESSAGE which results in the correct offset being used. To reduce the chance of breaking implementations that don't send the NTLMSSP_NEGOTIATE_VERSION flag in CHALLENGE_MESSAGE it is also added to NEGOTIATE_MESSAGE in the initial exchange.
Sorry Filip, |
That's essentially what it does unless you mean actually changing the In addition to that it always tries to negotiate the version from the start. W2K3 and older will reject it in CHALLENGE message, others will accept it and it will be present all throughout the exchange. That's mostly a safe guard against older broken implementations.
Happy to be beaten :) |
What I am saying is that the code needs to change to unconditionally add the version struct. It should not be conditional to whether MIC is requested. |
I changed the logic in The reason I didn't update The only problematic case is when version is not present and MIC is which is what I primarily tried to fix. If neither of them is present it's similar to the Windows 2003 (& older) behaviour. If both of them were present then the offsets were already matching. |
So I have a patch that just adds the wire_version everywhere: I do not think there is a big problem in practice, because we never decode the version field, and now we always add it there. |
Yeah, that's exactly why I didn't use that approach in the first place. I'd be happy to test your branch once that is fixed. I've two Windows servers to test against and my unit test server where I can deliberately produce old-style packets. |
@filipnavara check the current tip of the branch, I added also heuristics to support compatibility with older gssntlmssp version that would produce a mic at the wrong offset, as well as potentially other implementations that, as you noticed may completely omit the version struct. |
Ah wait forgot to fix this in ntlm_verify_mic where the same heuristics need to apply. |
No rush. I can do the basic tests against the servers now but running the full unit test will have to wait till tomorrow when I get to office. The connection to Windows Server 2022 seems to work but it still relies on the quirk where the server sends NTLMSSP_NEGOTIATE_VERSION in the CHALLENGE packet even if the client didn't send it in NEGOTIATE. gss-ntlmssp should really include it in the first NEGOTIATE packet. Not only is that what the Windows implementation does, it also allows to skip the heuristics for older gss-ntlmssp versions. The older versions would place the MIC at correct location if NTLMSSP_NEGOTIATE_VERSION was negotiated in the first place. |
I adjusted the code to properly check also when verifying the mic. |
I'll open a PR and we can continue discussion there. |
Opened #65 |
Fixed in #65 |
In most cases the change is bening because NTLMSSP_NEGOTIATE_VERSION
is sent by the server in CHALLENGE_MESSAGE and then repeated in
AUTHENTICATION_MESSAGE which results in the correct offset being used.
To reduce the chance of breaking implementations that don't send the
NTLMSSP_NEGOTIATE_VERSION flag in CHALLENGE_MESSAGE it is also added
to NEGOTIATE_MESSAGE in the initial exchange.
Fixes #62