-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
NTAuthentication.MakeSignature produces different thing on macOS, Windows and Linux #65678
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones Issue DetailsI've tried to make a test for On Windows it produces an output in the form (signature, message). I cannot find any justification in the specifications (GSSAPI, GSSAPI SASL mechanism, or NTLM) for prepending the length prefix. The reversed order of message and signature on macOS could be a bug in the provider default (https://github.com/apple-opensource/Heimdal/blob/9fed6a5818d85a439310b43727dd299366b397c2/lib/gssapi/ntlm/crypto.c#L699) but likely there's a way to enforce the proper order through different API call. The
|
Turns out that the order of GSS_Wrap is quite underspecified but the Windows call is way more explicit about the layout. On Windows the In GSSAPI there's a similar multiple-buffer API
This leads me to the following conclusion:
There doesn't seem to be an easy workaround for this. We can start using |
So, there is actually a way to detect the broken On the first wrap call for NTLM call Update: ...and quite obviously |
Still looking into a workaround that would work universally... Meanwhile, I have verified against Exchange server that the on-wire NTLM signed message in the GSSAPI authentication is in format (NTLM SIGNATURE | MESSAGE) or, in other words, (TRAILER | MESSAGE). |
The macOS Here's how it constructs the buffers:
The second buffer should have been |
Submitted feedback to Apple. For reference:
|
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsI've tried to make a test for On Windows it produces an output in the form (signature, message). I cannot find any justification in the specifications (GSSAPI, GSSAPI SASL mechanism, or NTLM) for prepending the length prefix. It could have been erroneously copied from the Encrypt operation which also seems to do the length prefixing on Windows. However, in the case of Encrypt it seems that the justification actually comes from the high-level NegotiateStream specification. The reversed order of message and signature on macOS could be a bug in the provider default (https://github.com/apple-opensource/Heimdal/blob/9fed6a5818d85a439310b43727dd299366b397c2/lib/gssapi/ntlm/crypto.c#L699) but likely there's a way to enforce the proper order through different API call.
|
Is there work we should do for 7.0 @filipnavara ? We generally depend on GSSAPI and I'm not sure how much we should fiddle with it. |
We can easily fix this on Linux (draft PR is submitted but the unit tests are issue we need to discuss). On macOS I submitted feedback to Apple and haven't heard back yet. |
No surprise there ;( Would this be still beneficial if we cannot fix all platforms and make it consistent? (and there are always old OS version...) |
Yep, fixing Linux is easy. Should I submit PR without the unit test part? |
Triage:
|
@filipnavara, are we looking to eventually move all platforms to the managed implementation? I think getting rid of krb5 build+run time dependency (pal_gssapi.c and related glue) would be a huge win as it will lower the system requirements bar, and it will possibly help mitigating these differences across platforms (predictable behavior). |
Probably not, at least not in short term. GSSAPI provides both Kerberos and NTLM authentication. While the managed NTLM implementation could easily be used on more platforms now, adding Kerberos would be a whole different goal. There is a managed implementation (https://github.com/dotnet/Kerberos.NET) but so far there was no effort or plan to integrate it or use it as a replacement for the system provided GSSAPI. I don't necessarily think it's a good idea to do so because of compatibility and size concerns. I am looking into supporting GSSAPI for Kerberos only and handling NTLM/Negotiate in the managed code. No firm commitment to that though. |
Thanks. Yes, it wasn't meant for ".NET 7 milestone" but for a general goodness moving forward into the future. :) I was thinking more about how SocketsHttpHandler has helped in the past (.NET Core 1.6 - 2.0 era) to gradually get rid of curl-dev dependency from .NET ecosystem in favor of fully managed implementation on all platforms; perhaps we can also move away from krb5-dev with similar plan in mind. |
We may do some transition over time @am11 if this turns out to be working well. For example, NTLM does not work in Azure functions because the underlying OS is missing gss-ntlm package. My original big motivation was macOS for developers, but @filipnavara figured out that the problem was so we were able to proceed with without switching to managed. Kerberos is whole different animal. I would like to use fragments of Kerberos.NET for testing but I'm not sure if this is going to really happen in 7.0. If the experience is good, we may look into it for platforms that do not have krb5. |
I've tried to make a test for
NTAuthentication.MakeSignature
only to find out that it produces different outputs on each OS.On Windows it produces an output in the form (signature, message).
On Linux it produces an output in form (length prefix, signature, message). The length prefix is generated in managed code.
On macOS it produces an output in form (length prefix, message, signature).
I cannot find any justification in the specifications (GSSAPI, GSSAPI SASL mechanism, or NTLM) for prepending the length prefix. It could have been erroneously copied from the Encrypt operation which also seems to do the length prefixing on Windows. However, in the case of Encrypt it seems that the justification actually comes from the high-level NegotiateStream specification.
MakeSignature
is not used in context ofNegotiateStream
though.The reversed order of message and signature on macOS could be a bug in the provider default (https://github.com/apple-opensource/Heimdal/blob/9fed6a5818d85a439310b43727dd299366b397c2/lib/gssapi/ntlm/crypto.c#L699) but likely there's a way to enforce the proper order through different API call.
The text was updated successfully, but these errors were encountered: