Repository navigation
[release/11.0] Honor explicit Unix NegotiateAuthentication server packages - #137245
Merged
Merged
Conversation
…36958) <!-- --> Unix `NegotiateAuthentication` servers using default credentials currently acquire GSSAPI acceptor credentials for all mechanisms, regardless of `NegotiateAuthenticationServerOptions.Package`. Consequently, a server requesting `Kerberos` can accept NTLM, and a server requesting `NTLM` can accept Kerberos. Windows already restricts the server to the explicitly selected package. - Pass the requested package through acceptor credential acquisition and restrict GSSAPI credentials to the Kerberos or NTLM mechanism as appropriate. - Reject completed server contexts whose protocol does not match an explicitly requested package, including credential paths that may acquire broader credentials. - Preserve the default `Negotiate` behavior, including NTLM fallback, and document the explicit-package restriction. - Add wrong-package rejection coverage, case-insensitive package checks, and successful same-package/Negotiate controls. Use a server-specific NTLM capability check so these initial-token tests run with OpenSSL 3 without enabling tests that require broken NTLM response generation. Related discussion: dotnet#136154 (comment) This intentionally changes Unix server behavior to match Windows: applications that previously relied on an explicit package accepting another mechanism must use `Negotiate` instead. Explicit mechanism credentials also reject SPNEGO-wrapped tokens; clients should select the server's explicit package, or the server should use `Negotiate`. Client package selection is unchanged. Linux validation used an isolated WSL Ubuntu 25.10 checkout with the same source changes. Windows validation used a short `subst` path to avoid path-length failures. - Windows: `R:\build.cmd clr+libs -rc release` — passed. - Windows: `.\.dotnet\dotnet.exe build src\libraries\System.Net.Security\tests\UnitTests\System.Net.Security.Unit.Tests.csproj /t:Test /p:RuntimeConfiguration=Release /p:XunitClassName=System.Net.Security.Tests.NegotiateAuthenticationTests` — 28 total, 0 failed, 4 skipped. - Linux: `./build.sh clr+libs -rc release` and `./build.sh libs -rc release` — passed. - Linux: `dotnet build src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj /t:Test /p:RuntimeConfiguration=Release /p:XunitClassName=System.Net.Security.Tests.NegotiateAuthenticationKerberosTest` — before the fix, all four wrong-package cases failed because NTLM returned `ContinueNeeded` or Kerberos returned `Completed`; after the fix, all 15 cases passed without skips. - Linux: `dotnet build src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj /t:Test /p:RuntimeConfiguration=Release` — 5,143 total, 0 failed, 8 skipped. - Linux: `dotnet build src/libraries/System.Net.Security/tests/UnitTests/System.Net.Security.Unit.Tests.csproj /t:Test /p:RuntimeConfiguration=Release` — 138 total, 1 failed, 12 skipped. The existing `Package_Unsupported_NTLM` test expects `Unsupported` but receives `ContinueNeeded` because its availability predicate excludes OpenSSL 3 and does not enable managed NTLM on Ubuntu 25.10. Reverting the product fix and rebuilding reproduced the identical failure and counts. - `git diff --check` — passed. macOS was not exercised. The Kerberos functional class is unsupported on Windows; it was not counted as Windows execution coverage. > [!NOTE] > This pull request and its description were created with GitHub Copilot. --------- Co-authored-by: Copilot App <[email protected]> (cherry picked from commit 796e892)
Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 4 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
Member
Author
|
/ba-g System.Net.Security tests pass |
Member
Author
|
Approved by Jeff Schwartz via email |
svick
approved these changes
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Issue N/A; reported in #136154 (comment).
main PR #136958
Customer Impact
A Unix server explicitly configured for Kerberos can accept NTLM, and a server configured for NTLM can accept Kerberos. Applications cannot rely on the selected server package to enforce their intended authentication protocol.
Regression
No known recent regression; this corrects a longstanding Unix/Windows behavioral inconsistency.
Testing
Added tests that check this in CI.
Risk
Small, this makes the behavior consistent across platforms, so we may break folks who rely on the inconsistent behavior, but that is exactly what we want to fix.
Note
This backport and its description were prepared with GitHub Copilot.