-
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
NegotiateAuthentication.ComputeIntegrityCheck on Windows sets an invalid QOP #103461
Comments
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
@filipnavara this is the issue I was talking about earlier. All good if you just want to close this but I thought I would report it in any case. |
cc @SteveSyfuhs for advice on using the API correctly. We lack test coverage for this on Windows, unfortunately. |
Well, we sort of support QOP for if (QualityOfProtection == KERB_WRAP_NO_ENCRYPT)
{
if (!Encrypt)
{
return STATUS_INVALID_PARAMETER;
}
Signature->SealAlgorithm[0] = KERB_GSS_NO_SEAL;
Signature->SealAlgorithm[1] = KERB_GSS_NO_SEAL_SECOND;
} I don't have a better answer on what is and isn't supported and by extension what the best way to call this is. Mixing and matching encrypt and sign is always a complex mess so I recommend staying continuous and always encrypting and signing everything, unless you must interop with something in particular that's doing weird things. |
Thanks, that implies we should change these lines: runtime/src/libraries/System.Net.Security/src/System/Net/NegotiateAuthenticationPal.Windows.cs Lines 590 to 591 in 5508f79
to just: int errorCode = Interop.SspiCli.MakeSignature(ref _securityContext._handle, 0, ref sdcInOut, 0); |
How does it interoperate with Linux? e.g. would it produce same result? |
I assume it would. We already specify runtime/src/native/libs/System.Net.Security.Native/pal_gssapi.c Lines 576 to 577 in f8f4509
Last night I tracked down the flags we pass on Windows to this article: https://learn.microsoft.com/en-us/windows/win32/secauthn/sspi-kerberos-interoperability-with-gssapi It was likely done under the assumption that
No. This should be a simple two line fix. |
Just as some background, I came across this when trying to implement support for |
Fix calling NegotiateAuthentication.ComputeIntegrityCheck on SSPI when the negotiation context was built with ProtectionLevel.Sign. The SECQOP_WRAP_NO_ENCRYPT QoP flag should not be set when calling GetMIC as no encryption is involved and some authentication providers fail when this is set. Fix dotnet#103461
I've opened #105605 which remove the QoP flag and always uses |
Fix calling NegotiateAuthentication.ComputeIntegrityCheck on SSPI when the negotiation context was built with ProtectionLevel.Sign. The SECQOP_WRAP_NO_ENCRYPT QoP flag should not be set when calling GetMIC as no encryption is involved and some authentication providers fail when this is set. Fix dotnet#103461 Co-authored-by: Tomas Weinfurt <tweinfurt@yahoo.com>
Description
When using
NegotiateAuthentication.ComputeIntegrityCheck
on Windows with a context withSign
and notEncryptAndSign
, it calls MakeSignature with the QoP value of SECQOP_WRAP_NO_ENCRYPT. This fails withSEC_E_INVALID_TOKEN
because as far as I know this QoP setting is forEncryptMessage
and notMakeSignature
.Reproduction Steps
In this case I'm running as a domain user that has added
test/dotnet
as aservicePrincipalName
to its AD account. This allows me to replicate Kerberos authentication in the same process when running as that user.Expected behavior
Signature is generated
Actual behavior
Exception,
MakeSignature
fails withSEC_E_INVALID_TOKEN
.Regression?
No
Known Workarounds
Ensure you set the NegotiateAuthenticationClientOptions.RequiredProtectionLevel to
EncryptAndSign
and notSign
. I don't believe this would cause an issue except that it would just request extra capabilities but I don't believe you should have to request confidentiality if all you need is integrity.Configuration
.NET Version - 9.0.100-preview.5.24307.3
OS - Windows Server 2022
Arch - x64
I don't believe this is specific to the OS or arch version. I believe SSPI doesn't accept any QoP values for
MakeSignature
, at least for the builtin authentication providers.Other information
No response
The text was updated successfully, but these errors were encountered: