-
Notifications
You must be signed in to change notification settings - Fork 100
Ensure cname precisely matches what was in request #407
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
base: develop
Are you sure you want to change the base?
Conversation
f61c048 to
cda9b28
Compare
| [Obsolete( | ||
| "Using SamAccountName may cause non spec-compliant behavior. Use ClientName instead to set the client " + | ||
| "principal name that should be used in Kerberos responses in a spec-compliant manner.")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this obsolete because you can achieve the same result via ClientName (and you have more control over the number of Name parts, and the Type of the principal name).
Also I wanted to ensure Kerberos.NET avoids using SamAccountName as much as possible, as it's the cause of non spec compliant behavior -- and that any usages are appropriately marked as dangerous / deprecated way of doing things.
But I think it's debatable if it really should be marked as deprecated. Happy to roll this back if you would rather keep it as-is.
What's the problem?
The current handling of cname is not always spec-compliant. The spec requires the Kerberos server to essentially echo back cname and crealm to the client. However, in some scenarios, Kerberos.NET responds with a slightly different cname.
This is an issue for Kerberos clients that check that the cname in the response exactly matches what was in the request (such as MIT krb5, see code pointer).
The current handling of cname is only subtly wrong. It works in the most common scenario (let's call this scenario 1), where:
["username", "realm"]"realm"However, it does not work in this scenario (let's call this scenario 2):
["username"]"realm"This latter scenario can occur in practice. For instance, see the Wireshark trace below, where a Linux client got a referral TGT from an on-prem AD DS server. The cname only has one part.
Using this referral TGT gave
What's the solution?
Currently Kerberos.NET uses
crealmandcnamefrom the request toFindanIKerberosPrincipal, and then re-constructscnameandcrealmfields in the response from the found principal.However, this conversion from
cname/crealmtoIKerberosPrincipalisn't injective. In both scenarios 1 and 2, we can find the same client principal from thecnameandcrealmfields. When we convert that principal back tocnameandcrealm, we don't necessarily get the same values back.The solution is to copy cname and crealm from the request. This aligns with the spec, section 3.3.3 Generation of KRB_TGS_REP Message:
What issue is this related to, if any?
None.