Kerberos
For Kerberos we have a /etc/krb5.conf file that has the configuration. How sensitive is the contents of this file?
What is the best way of managing Kerberos access? I get the impression that anything which requires getpwnam(3) access will need to read /etc/krb5.conf and access the network. This means that when kerberos is enabled we need to allow almost all programs to have network access and read access to krb5.conf .
Would it be possible to change the kerberos libraries to spawn a child process similar in nature to unix_chkpwd to perform the kerberos functions?
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
Russell> For Kerberos we have a /etc/krb5.conf file that has the Russell> configuration. How sensitive is the contents of this Russell> file?
All clients and servers need read access. Even if the contents of krb5.conf, the worst that could happen is a denial-of-service attack by pointing programs to the wrong KDC.
It would not be possible to trick clients into using the wrong KDC unless the secret key used has been compromised (eg. the users password, /etc/krb5.keytab, or, worst case, the KDC itself). In fact, the most important details from krb5.conf can also be configured in DNS.
This however implies that /etc/krb5.keytab needs to be kept under very tight control; It contains any number of secret keys.
Russell> Would it be possible to change the kerberos libraries to Russell> spawn a child process similar in nature to unix_chkpwd to Russell> perform the kerberos functions?
I don't think this would help for krb5.conf, but it might help for /etc/krb5.keytab.
I am not that familiar with the API used in the Kerberos libraries, so I don't know how feasible this is. It could be that the API is inappropriate for this split.
The concept though would be to have a child process that takes the name of the file (/etc/krb5.keytab), the name of the key within this file, and it will decrypt data given with this key.
That way, the daemon never needs access to the secret key.
Signature · 6 lines
Brian May <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 9 lines · Brian May
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
Russell> For Kerberos we have a
/etc/krb5.conffile that has the Russell> configuration. How sensitive is the contents of this Russell> file?All clients and servers need read access. Even if the contents of krb5.conf, the worst that could happen is a denial-of-service attack by pointing programs to the wrong KDC.
I'm not sure what you mean by this. Are you saying that the worst that can happen from unauthorised writes to krb5.conf is a DOS attack?
Quoted 8 lines
It would not be possible to trick clients into using the wrong KDC unless the secret key used has been compromised (eg. the users password,
/etc/krb5.keytab, or, worst case, the KDC itself). In fact, the most important details from krb5.conf can also be configured in DNS.This however implies that
/etc/krb5.keytabneeds to be kept under very tight control; It contains any number of secret keys.
To clarify. krb5.conf is like /etc/passwd and krb5.keytab is like /etc/shadow ?
Quoted 6 lines
Russell> Would it be possible to change the kerberos libraries to Russell> spawn a child process similar in nature to
unix_chkpwdto Russell> perform the kerberos functions?I don't think this would help for krb5.conf, but it might help for
/etc/krb5.keytab.
So most programs access krb5.conf, while only /bin/login and equivalent programs access krb5.keytab (like the passwd and shadow files)?
Quoted 3 lines
I am not that familiar with the API used in the Kerberos libraries, so I don't know how feasible this is. It could be that the API is inappropriate for this split.
I can't imagine how it could be impossible to do this. The worst-case scenario is that you have a dialog between client and server which requires two pipes for communication between the unpriv process and the program that's like unix_chkpwd.
Quoted 5 lines
The concept though would be to have a child process that takes the name of the file (
/etc/krb5.keytab), the name of the key within this file, and it will decrypt data given with this key.That way, the daemon never needs access to the secret key.
Sounds good. How difficult do you think it would be to implement this for Heimdal?
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
All clients and servers need read access. Even if the
contents of krb5.conf, the worst that could happen is a denial-of-service attack by pointing programs to the wrong KDC.
Russell> I'm not sure what you mean by this. Are you saying that Russell> the worst that can happen from unauthorised writes to Russell> krb5.conf is a DOS attack?
Correct.
Quoted 9 lines
Quoted 9 lines
It would not be possible to trick clients into using the wrong KDC unless the secret key used has been compromised (eg. the users password,
/etc/krb5.keytab, or, worst case, the KDC itself). In fact, the most important details from krb5.conf can also be configured in DNS.This however implies that
/etc/krb5.keytabneeds to be kept under very tight control; It contains any number of secret keys.
Russell> To clarify. krb5.conf is like /etc/passwd and Russell> krb5.keytab is like /etc/shadow ?
Sort of, except security is breached if /etc/passwd is altered in anyway (I could set my account to be uid=0 for instance), but it isn't so critical for /etc/krb5.conf. Small point, it probably isn't significant as far as SE-Linux support is concerned.
Russell> So most programs access krb5.conf, while only /bin/login Russell> and equivalent programs access krb5.keytab (like the Russell> passwd and shadow files)?
Yes. All programs access krb5.conf; only servers need access to krb5.keytab (and login). kinit does not need access to krb5.keytab.
Russell> Sounds good. How difficult do you think it would be to Russell> implement this for Heimdal?
No idea, it might be worth investigating some time.
Signature · 6 lines
Brian May <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · Brian May
Russell> To clarify. krb5.conf is like
/etc/passwdand Russell> krb5.keytab is like/etc/shadow?Sort of, except security is breached if
/etc/passwdis altered in anyway (I could set my account to be uid=0 for instance), but it isn't so critical for/etc/krb5.conf. Small point, it probably isn't significant as far as SE-Linux support is concerned.
OK, but the main thing is that there is no reason to label that file differently to /etc/passwd (which has etc_t - IE no special labeling).
Quoted 6 lines
Russell> So most programs access krb5.conf, while only
/bin/loginRussell> and equivalent programs access krb5.keytab (like the Russell> passwd and shadow files)?Yes. All programs access krb5.conf; only servers need access to krb5.keytab (and login). kinit does not need access to krb5.keytab.
So it seems that a simple way to write policy for Kerberos would be to have krb5.conf labeled as etc_t, krb5.keytab labeled at kerberos_secret_t, and have the following in domains/misc/kerberos-client.te:
allow { auth auth_chkpwd } kerberos_secret_t:file { getattr read }; can_network({ auth auth_chkpwd })
ifdef(kerberos.te', can_tcp_connect({ auth auth_chkpwd }, kerberosd_t)
')
That just leaves the issue of allowing kerberos getpwnam(3) operations, Steve didn't like what I did for nscd. Maybe if we just allow it for userdomain and then test all the daemons to see which ones need it, and have a macro can_lookup_user() which will do appropriate things for kerberos, nscd, LDAP, etc.
Quoted 4 lines
Russell> Sounds good. How difficult do you think it would be to Russell> implement this for Heimdal?
No idea, it might be worth investigating some time.
I was hoping that you would rush off and do it. ;)
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
Russell> So it seems that a simple way to write policy for Russell> Kerberos would be to have krb5.conf labeled as etc_t, Russell> krb5.keytab labeled at kerberos_secret_t, and have the Russell> following in domains/misc/kerberos-client.te:
Russell> allow { auth auth_chkpwd } kerberos_secret_t:file { getattr read }; Russell> can_network({ auth auth_chkpwd })
Russell> ifdef(kerberos.te',
Russell> can_tcp_connect({ auth auth_chkpwd }, kerberosd_t) Russell> ')
This is for the server, right?
The client doesn't need access to kerberos_secret_t, only servers.
Or perhaps I am confused with a different meaning for the word "client"?
Here, for client, I consider ssh, telnet, etc to be clients and sshd, telnetd, etc to be servers.
Signature · 6 lines
Brian May <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · Brian May
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
Russell> So it seems that a simple way to write policy for Russell> Kerberos would be to have krb5.conf labeled as
etc_t, Russell> krb5.keytab labeled atkerberos_secret_t, and have the Russell> following in domains/misc/kerberos-client.te:
Quoted 7 lines
Russell> allow { auth
auth_chkpwd} kerberos_secret_t:file { getattr
read }; Russell>can_network({ auth auth_chkpwd })
Russell> ifdef(kerberos.te',
Russell>can_tcp_connect({ auth auth_chkpwd }, kerberosd_t)Russell> ')This is for the server, right?
kerberos.te is for the Kerberos server. The policy I suggested above is for Kerberos clients such as sshd, which need to access the secret file, the network, and TCP connections to the local kerberos server (if there is one).
Quoted 1 line
The client doesn't need access to
kerberos_secret_t, only servers.
The krb5.keytab file needs to be accessed by kerberos clients such as login and sshd.
Quoted 5 lines
Or perhaps I am confused with a different meaning for the word "client"?
Here, for client, I consider ssh, telnet, etc to be clients and sshd, telnetd, etc to be servers.
For kerberos sshd is a client and the Kerberos server is the server.
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
Or perhaps I am confused with a different meaning for the word "client"?
Here, for client, I consider ssh, telnet, etc to be clients and sshd, telnetd, etc to be servers.
Russell> For kerberos sshd is a client and the Kerberos server is Russell> the server.
I see your point, but this gets a bit messy; sshd never actually talks to the KDC server. ssh does.
Signature · 6 lines
Brian May <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 4 lines · Brian May
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
Or perhaps I am confused with a different meaning for the word "client"?
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Here, for client, I consider ssh, telnet, etc to be clients and sshd, telnetd, etc to be servers.
Russell> For kerberos sshd is a client and the Kerberos server is Russell> the server.
I see your point, but this gets a bit messy; sshd never actually talks to the KDC server. ssh does.
Could you please give me a summary of how Kerberos works in terms of SE Linux. What talks to what by what mechanism, and when it does so.
It seems that I don't understand how this is supposed to work.
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Russell" == Russell Coker <[email protected]> writes:
Russell> Could you please give me a summary of how Kerberos works Russell> in terms of SE Linux. What talks to what by what Russell> mechanism, and when it does so.
Russell> It seems that I don't understand how this is supposed to Russell> work.
In order to allow user U to use server S, the user needs a ticket, T(U,S).
Initially the first server the user will (almost always) get access to is the TGS (ticket granting server), which will then give tickets for any other server.
In order to simplify the following, I have eliminated stuff used to prevent replay attacks. I am also assuming that the user obtains the ticket to use the desired service on first contact with the KDC, as the TGS is just a service like any other (with the exception it is provided by the KDC).
Note:
1. The KDC is the secure server acting as the third party and has all secret keys.
2. Only the KDC and the user know K(U), the user's password.
3. Only the KDC and the server know K(S), the secret key for service S. This is stored in /etc/krb5.keytab on the server.
4. I have used server to mean the server that the client/user connects to.
To summarise:
1. To use service S, user U obtains a ticket, either using kinit, or the Kerberos PAM module. Internally (for kinit) this:
a) asks the user for their password, K(U).
b) sends a request to the KDC server.
c) receives the response. There are two parts:
1. A session key that is encrypted with K(U), this is decrypted.
2. A session key that is encrypted with K(S), the user can't access this.
The fact that the response was decrypted proves that the remote KDC is the correct one, as only it could encrypt the response with the users password.
2. The user later on needs to use service S. The "authenticator" is sent to the server. This includes:
a) The session key encrypted with K(S).
b) The name of the client (according to my notes, not sure of this) encrypted with the session key.
The server then decrypts the session key with K(S). It then decrypts the rest of the data with the session key. It now has authenticated the user, as only the U and S could encrypt data with the session key (actually the KDC also could, but we are assuming it is trusted[1]). It can then use this session key to talk to the client. If it sends a message to the client encrypted with the session key, the client can authenticate the server.
As far as SE-Linux is concerned, there are several week points:
1. User enters the password, which is used to decrypt the session key, Possibly SE-Linux can prevent core dumps, strace, gdb, of kinit. This might help to some degree. kinit is just a normal non-setuid not-setguid executable.
2. The server only needs to decrypt the session key, but has access to all Kerberos secret keys stored on that computer; this is what I speculated could be fixed with the helper program.
3. On the KDC, only the KDC server should have any access to the KDC secret data. In fact, you could argue that not even the administrator should have access (except for initial installation).
I hope this helps clarifies the process. This is all mostly from memory, and from my thesis, because it was so long ago when I worked on it.
Note:
[1] There was an extension to the Kerberos protocol to so even the KDC doesn't know the session key. Diffie Hellman??? I can't remember the details.
Signature · 6 lines
Brian May <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.