I've tried to figure out how kerberos authentication works, the information which I found was always missing something as if a part of it was taken for granted. I am aware of the process in general but missing some details.
Getting TGT:
First a user should get a TGT (Ticket Granting Tickets) from the KDC - the user sends a request with only it's user name (UPN) and without it's password. Some extra information is given to prevent a resent of the request such as ip address and a timestamp. If preauthentication is required then the time is hashed with the user's password.
The KDC is sending the user back the following:
A. TGT - with a timestamp, user name, ip address and a session key - the TGT is encrypted with a secret only the KDC knows and therefore cannot be changed by anyone.
B. Session key for the user and the KDC to be used in later communication.
Those things are encrypted using the users password (a basic shared secret amongst the KDC and the user).
In case a preauthentication was used the server will check if the timestamp was valid before sending the information back.
The users receive the information and decrypt it using it's password - and then stores it in it's memory (kerberos tray).
Getting TGS:
When the user is requested to authenticate itself from a service he sends a request to the KDC for a TGS (Ticket Granting Service), the request contains the TGT, UPN and the SPN (Service Principal Name - say, the URI of a webpage).
The KDC then decrypts the TGT and validate it's authenticity, that it is corresponds with the UPN, from the same IP address and still valid (the ticket has an effective time period).
The KDC sends a TGS to the user encrypted with the service password.
The user presents the TGS to the service - which decrypts it using it's own password.
The authentication is complete since the service counts on the fact that it's password is only shared between it and the KDC so it trusts that the KDC authenticated the user earlier.
A few questions:
Am I missing something or that's it?
When does the user and the KDC ever use the session key? At what point? Why is it necessary? Why does the user password isn't enough?
There should also be a session key between the user and the service (to the best of my knowledge) - when and why is it used (same as the last question)?
Kerberos has a 5 minute gap limitation between all parties - I understand why keeping the time in sync is important since it is used as something that we encrypt and decrypt so how come any gap is OK? Why 5 minutes?
I'll be glad for any corrections if you have.
Thanks in advance, Tomer
So, I think I've found the answer.
I'll make a few corrections since the question has some inaccuracies.
Getting TGT:
- First a user should get a TGT (Ticket Granting Tickets) from the KDC - the user sends a request with only it's user name (UPN) and without it's password. Some extra information is given to prevent a resent of the request such as ip address and a timestamp. If preauthentication is required then the time is hashed with the user's password.
- The KDC is sending the user back the following:
A. TGT - with a timestamp, user name, ip address and a session key - the TGT is encrypted with a secret only the KDC knows and therefore cannot be changed by anyone.
All of this are simply called an "authenticator".
B. Session key for the user and the KDC to be used in later communication. Those things are encrypted using the users password (a basic shared secret amongst the KDC and the user). In case a preauthentication was used the server will check if the timestamp was valid before sending the information back.
The TGT itself is only hashed by the KDC's secret and not also at the user's password.
- The users receive the information and decrypt it using it's password - and then stores it in it's memory (kerberos tray).
Getting TGS:
- When the user is requested to authenticate itself from a service he sends a request to the KDC for a TGS (Ticket Granting Service), the request contains the TGT, UPN and the SPN
The request also include a fresh authenticator (instead of the UPN mentioned) which the KDC will check against the one that is in the TGT. The authenticator is encrypted using the session key of the user and the KDC. The KDC will decrypt the TGT using it's password and then extracts the session key from it (it does not saves the information on it) and next decrypts the authenticator using the session key.
(Service Principal Name - say, the URI of a webpage).
An SPN doesn't contain a URI - it contains the host, the service and a port - something like that: HTTP/localhost:80 Or ldap/localdc. port number could be omitted if default port is used (such as 80 for HTTP or 389 for ldap).
- The KDC then decrypts the TGT and validate it's authenticity, that it is corresponds with the UPN, from the same IP address and still valid (the ticket has an effective time period). 3. The KDC sends a TGS to the user encrypted with the service password.
The KDC also sends a session key for the client and the user to use later on. it sends it encrypted in the session key of the KDC and the user from earlier - another copy of the session key (of client and the server) is inside the TGS itself, inside the TGS also resides an authenticator of the client.
- The user presents the TGS to the service - which decrypts it using it's own password. 5. The authentication is complete since the service counts on the fact that it's password is only shared between it and the KDC so it trusts that the KDC authenticated the user earlier.
The user also sends an authenticator encrypted with the session key of the client and the server. The server then decrypts the TGS using it's password - extracts the session key from the TGS and uses it to decrypt the authenticator and compares it to the one in the TGS. If valid then the authentication of the client is complete. Kerberos also features an option for the client to authenticate the server (called mutual authentication) - if a flag of mutual authentication is sent by the client then there is another step.
A few questions:
- Am I missing something or that's it?
- When does the user and the KDC ever use the session key? At what point? Why is it necessary? Why does the user password isn't enough?
- There should also be a session key between the user and the service (to the best of my knowledge) - when and why is it used (same as the last question)?
- Kerberos has a 5 minute gap limitation between all parties - I understand why keeping the time in sync is important since it is used as something that we encrypt and decrypt so how come any gap is OK? Why 5 minutes?
Hoped it helps.
All of the things are in this link (very repetitive if one is reading the whole thing from the start to the end - you should read only the part that you want to understand) - Https://Technet.microsoft.com/en-us/library/cc772815(v=ws.10).aspx
And I also read a bit of the RFC - https://www.rfc-editor.org/rfc/rfc1510
And two less detailed links:
https://technet.microsoft.com/en-us/library/cc961976.aspx
https://technet.microsoft.com/en-us/library/aa480475.aspx (deals with IIS authentication - there is a part where kerberos is mentioned and explained a bit).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With