-
Notifications
You must be signed in to change notification settings - Fork 65
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
Kerberos broken in recent nanoserver images #537
Comments
Thank you for creating an Issue. Please note that GitHub is not an official channel for Microsoft support requests. To create an official support request, please open a ticket here. Microsoft and the GitHub Community strive to provide a best effort in answering questions and supporting Issues on GitHub. |
I'm trying to reproduce but the above command " Invoke-WebRequest -UseBasicParsing -UseDefaultCredentials -AllowUnencryptedAuthentication "http:57.151.34.124/hello" |
hi @zylxjtu - could you please try PowerShell Core/7.1. I don't know what's equivalent of |
This issue has been open for 30 days with no updates. |
No updates on this yet from the internal team. |
Describe the bug
It looks like
nanoserver-ltsc2022
images released in April 2024 and later have broken Kerberos.To Reproduce
First, create a simple ASP.NET Core project
AspNetKerbHello
.Create
AspNetKerbHello.csproj
with the following content:Now, create
Program.cs
with the following content - we are enabling negotiate authentication here:Now build the above project, using
dotnet build
command.Now, inside the build output directory where
AspNetKerbHello.dll
is present, create aDockerfile
with the following content. We are purposefully pulling .NET runtime8.0.4
because it uses nanoserver image from April 2024 - i.e.mcr.microsoft.com/windows/nanoserver:ltsc2022-KB5036909
-- but this works with even the latest nanoserver image:Now build this docker image, let's assume it's tagged
aspnetkerbhello:v1
:docker build -t aspnetkerbhello:v1 .
Now run this image in Kubernetes as a gMSA that owns a SPN
Now, access the Kubernetes SVC URI - assuming the SPN owned by the gMSA is
http/<FQDN>
whereFQDN
is Kubernetes SVC domain name. In the below example SPN ishttp/my-svc.my-namespace.svc.cluster.local
:Assuming NTLM is disabled and authentication is happening over Kerberos, you will get HTTP 500 error with an exception containing the following error callstack in the Kubernetes pod logs:
If you made a mistake somewhere, you will instead get authenticated over NTLM and won't see the error - rather a 200 OK page with the following message:
The issue only occurs when using Kerberos, not NTLM.
Now, all of the above can be also done without involving Kubernetes with a docker container running with gMSA cred-spec file but it's bit tricky - you need to first enable Kerberos on loopback using
DisableLoopbackCheck
registry key, and then use[System.Net.AuthenticationManager]::CustomTargetNameDictionary
to maplocalhost
to the SPN owned by the gMSA; and even then you might endup with NTLM. So I recommend using Kubernetes for testing the above.You do not need multiple replicas. Even just a single pod runs into the above error.
I know the issue isn't because of any change in the .NET runtime version because I have created a custom .NET runtime image with the exact same runtime version (
8.0.4
) but older (March 2024) nanoserver base image and I couldn't repro the issue - suggesting the issue is in the nanoserver base image.Expected behavior
Kerberos should work with nanoserver images
Configuration:
Additional context
Per dotnet/runtime#105567 (comment) the error
System.Net.InternalException: Exception of type 'System.Net.InternalException' was thrown. -1073741428
translates toERROR_TRUSTED_DOMAIN_FAILURE
orThe trust relationship between the primary domain and the trusted domain failed
, so I suspect this is likely related to the other gMSA issue #405The text was updated successfully, but these errors were encountered: