Skip to content

Segmentation violation when doing server-side Kerberos authentication on macOS #71463

Description

@filipnavara

The following repo crashes with segmentation violation in gss_delete_sec_context.

Steps:

  1. Compile and run Kerberos.NET KerberosKdcHostApp sample. Note that it may require some tweaks since it currently has internal project dependencies that prevent it from being built on non-Windows.
  2. Create a krb5.conf file with the following content:
[realms]
corp2.identityintervention.com = {
kdc = tcp/127.0.0.1:8888
}
  1. Create a krb5.keytab file with the following command:
ktutil --keytab=./keytab add -p HTTP/corp2.identityintervention.com@corp2.identityintervention.com
Encryption type: aes256-cts-hmac-sha1-96
Key version: 1
Password: P@ssw0rd!
  1. Set KRB5_CONFIG environment variable to path to krb5.conf from step 2
  2. Set KRB5_KTNAME environment variable to path to krb5.keytab from step 3
  3. Create a new dotnet program with dotnet new console and replace the content of Program.cs with
usingSystem.Net;usingSystem.Net.Security;NegotiateAuthenticationClientOptionsclientOptions=newNegotiateAuthenticationClientOptions{Credential=newNetworkCredential("user","P@ssw0rd!","corp2.identityintervention.com"),TargetName="HTTP/corp2.identityintervention.com"};NegotiateAuthenticationServerOptionsserverOptions=newNegotiateAuthenticationServerOptions{};NegotiateAuthenticationclientNegotiateAuthentication=newNegotiateAuthentication(clientOptions);NegotiateAuthenticationserverNegotiateAuthentication=newNegotiateAuthentication(serverOptions);NegotiateAuthenticationStatusCodestatusCode;byte[]?serverBlob=null;byte[]?clientBlob=null;do{clientBlob=clientNegotiateAuthentication.GetOutgoingBlob(serverBlob,outstatusCode);Console.WriteLine("client status: "+statusCode);Console.WriteLine("client blob: "+(clientBlob==null?"null":Convert.ToHexString(clientBlob)));if(clientBlob!=null){Console.WriteLine("client -> server ");serverBlob=serverNegotiateAuthentication.GetOutgoingBlob(clientBlob,outstatusCode);Console.WriteLine("client -> server 2");Console.WriteLine("server status: "+statusCode);Console.WriteLine("server blob: "+(serverBlob==null?"null":Convert.ToHexString(serverBlob)));}}while(serverBlob!=null);
  1. Update the .csproj file from step 6 to target net7.0 (preview6+ is required)
  2. Run the program with dotnet run

The output is

client status: ContinueNeeded
client blob: 607406062B0601050502A06A3068A01E301C06062B060105050E060A2B06010401823702020A06062B0601050205A2460444604206062B060105050E6E2C6E3D7573657240636F7270322E6964656E74697479696E74657276656E74696F6E2E636F6D2C723D4677774564416832684E687164484B35
client -> server client -> server 2
server status: ContinueNeeded
server blob: A1153013A0030A0101A10C060A2B06010401823702020A
client status: ContinueNeeded
client blob: A12E302CA22A04284E544C4D535350000100000005028862000000000000000000000000000000000601B01D0000000F
client -> server zsh: segmentation fault ./bin/Debug/net7.0/negotest

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions