Skip to content
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

ownership and permission of keytab file #1982

Closed
rptaylor opened this issue Mar 29, 2023 · 5 comments
Closed

ownership and permission of keytab file #1982

rptaylor opened this issue Mar 29, 2023 · 5 comments

Comments

@rptaylor
Copy link

rptaylor commented Mar 29, 2023

Hello,

Regarding the xrootd keytab file, it seems that xrootd server running as the daemon user fails to start if the file ownership is different from

-r--------. 1 daemon daemon 143 Mar 29 00:34 eos.keytab

Would you consider allowing this?

-r--r-----. 1 root daemon 143 Mar 29 00:34 eos.keytab

The error comes from here: https://github.com/xrootd/xrootd/blob/master/src/XrdSecsss/XrdSecsssKT.cc#L439

sh-4.2$ /opt/eos/xrootd/bin/xrootd -n mgm -c /etc/xrd.cf.mgm -m
230329 01:06:07 059 Starting on Linux 4.18.0-425.13.1.el8_7.x86_64
230329 01:06:07 059 /opt/eos/xrootd/bin/xrootd -n mgm -c /etc/xrd.cf.mgm -m
Copr.  2004-2012 Stanford University, xrd version v20220719-3cc9438
++++++ xrootd mgm@eos-mgm-0.eos-mgm.eos.svc.kermes-dev.local initialization started.
Config using configuration file /etc/xrd.cf.mgm
=====> xrd.sched mint 8 maxt 256 idle 64
230329 01:06:07 059 XrdConfig: Unable to create home directory //mgm; permission denied
Config maximum number of connections restricted to 1048576
Copr.  2012 Stanford University, xroot protocol 5.1.0 version v20220719-3cc9438
++++++ xroot protocol initialization started.
230329 01:06:07 059 XrootdConfig: non-absolute export path - -m
=====> xrootd.fslib libXrdEosMgm.so
=====> xrootd.seclib libXrdSec.so
=====> xrootd.async off nosf
=====> xrootd.chksum eos
=====> all.export / nolock
Config exporting /
Plugin loaded unreleased secprot v20220719-3cc9438 from seclib libXrdSec-5.so
++++++ Authentication system initialization started.
Plugin loaded unreleased secunix v20220719-3cc9438 from sec.protocol libXrdSecunix-5.so
=====> sec.protocol unix
Plugin loaded unreleased secsss v20220719-3cc9438 from sec.protocol libXrdSecsss-5.so
Secsss (getKeyTab): Unable to process /etc/eos.keytab; file is not secure!

Keytab file is not secure!
Config Failed to load sss authentication protocol!

The error message is not entirely accurate because the proposed file mode/ownership is equally secure, because root can implicitly read all files regardless of ownership. xrootd should not care whether it can read the keytab file via user ownership or group ownership, it should only matter that it can open the file read-only and that it is not publicly readable.

This will help in environments where credentials are provided for the xrootd server but owned and managed by the root user (for example in kubernetes where the keytab is injected as a secret into the pod by the kubelet).

Thanks!

@abh3
Copy link
Member

abh3 commented Mar 29, 2023

Taken at face value, it really is not as secure because we have no idea who is in the daemon group (and please don't ask us to verify that it is a singleton). Since if root created the file it can just as easily assign the ownership to daemon. The message, I would argue, is correct for the reasons I stated above. What worries me more is that the home directory could not be created and that prevents getting any core files should he serve crash.

@rptaylor
Copy link
Author

rptaylor commented Mar 29, 2023

Is keeping the keytab file secure the responsibility of xrootd or the administrator? I think an application should take some reasonable precautions and/or print helpful warnings, but it is ultimately the responsibility of and should be under control of the administrator. Likewise for ensuring the group is a singleton. xrootd can not absolutely ensure the confidentiality of the keytab file. I could always accidentally paste it on github or something :)

if root created the file it can just as easily assign the ownership to daemon.

That is not possible in this case, because the secret is managed by the kubelet and the file is mounted into all containers of a pod, but each container in a pod may have a different identity context which would lead to UID conflicts. Besides, this is not running on a traditional server where there are other users. It is running in a pod where there is only one parent process running with a completely arbitrary UID and GID. It's kind of like the 'O' field in 'UGO' is irrelevant because it is an isolated environment with no other users (or you can think of all the processes allowed to run in the container as being the "group" of the container), the U field has to be root as explained above, so the G field is used for ownership of the file.
U -> -
G -> U
O -> G

Some applications (such as Postgres and arcproxy) which had assumptions about the security context of a traditional server have relaxed those requirements a bit to allow admins more control in how they deploy services (for example on Kubernetes) and to adapt to being more container-native.

If the pod crashes it will be restarted automatically and any transient files will be lost. The pod could be instrumented to retain core files though, e.g. in /mgm. But either way the concept of a home directory doesn't really apply in this context.

Thanks for your consideration!

@abh3
Copy link
Member

abh3 commented Mar 29, 2023 via email

@rptaylor
Copy link
Author

It is the responsibility of the application to verify that the admin has kept the file secure.

The application is limited to only seeing the owner and mode of the file on the local filesystem, which is a small subset of all that encompasses keeping the keytab secure. In our environment the mode 0440 root:daemon is correct and secure.
How can we indicate this to xrootd and prevent it from making incorrect assumptions about the environment it is operating it? Perhaps a non-default command-line option could be implemented, to change the error to a warning and not terminate?

@abh3
Copy link
Member

abh3 commented Oct 12, 2023

This is a security level disagreement. Best practices generally disallow people from stepping into a security minefield even if they want to and his is what xroot does here. So, we will keep the current behaviour.

@abh3 abh3 closed this as completed Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants