too many sysadmfile?
One thing that hasn't sat well with me for a long time is that just about all file_types are sysadmfile in the strict policy. To me, this sounds like an excessive amount of access for sysadm_t (with exception of the unrestricted_admin tunable being on).
Its true that since sysadm_t can already relabel almost everything, it makes this change moot from a security perspective, since it can relabel a file to something it can modify. However, by limiting normal access, it affords some protection against accidental overwrites and deletions, and from malicious programs a sysadmin might accidentally run. In my opinion, the packagers (rpm_t, etc) should be the only ones with access all file_types.
I haven't looked into it much, but my idea is eliminate sysadmfile except where its obviously warranted, such as in /etc/* types. Then change the sysadmfile policy in admin_domain to something like:
ifdef(unrestricted_admin', create_dir_notdevfile($1_t,{ file_type -device_type -shadow_t }) ',`create_dir_notdevfile($1_t,sysadmfile)
')
Or maybe use a boolean could be used, instead of a tunable. Then change the relabeling rule to:
# Relabel all files except shadow_t.
allow $1_t { file_type -shadow_t }:dir { getattr read search relabelfrom relabelto }; allow $1_t { file_type -shadow_t }:file_class_set { getattr relabelfrom relabelto };
Comments?
Signature · 13 lines
Chris PeBenito <[email protected]> Developer, Hardened Gentoo Linux Embedded Gentoo Linux Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243 Key fingerprint = B0E6 877A 883F A57A 8E6A CB00 BC8E E42D E6AF 9243 -- 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 23 lines · Chris PeBenito
One thing that hasn't sat well with me for a long time is that just about all
file_typesare sysadmfile in the strict policy. To me, this sounds like an excessive amount of access forsysadm_t(with exception of theunrestricted_admintunable being on).Its true that since
sysadm_tcan already relabel almost everything, it makes this change moot from a security perspective, since it can relabel a file to something it can modify. However, by limiting normal access, it affords some protection against accidental overwrites and deletions, and from malicious programs a sysadmin might accidentally run. In my opinion, the packagers (rpm_t, etc) should be the only ones with access allfile_types.I haven't looked into it much, but my idea is eliminate sysadmfile except where its obviously warranted, such as in
/etc/*types. Then change the sysadmfile policy inadmin_domainto something like:ifdef(
unrestricted_admin',create_dir_notdevfile($1_t,{ file_type -device_type -shadow_t })',`create_dir_notdevfile($1_t,sysadmfile)
')
Quoted 8 lines
Or maybe use a boolean could be used, instead of a tunable. Then change the relabeling rule to:
# Relabel all files except
shadow_t.
allow $1_t {file_type-shadow_t }:dir { getattr read search relabelfrom relabelto }; allow $1_t {file_type-shadow_t }:file_class_set { getattr relabelfrom relabelto };Comments?
A commendable goal, but you need to gradually migrate toward such a scheme, as existing usage assumes direct access by admins running common utilities, using shell redirection, etc. The strict policy (with unrestricted_admin disabled) does prevent direct access to some types (e.g. devices), but certainly not many, as you noted. With regard to malicious programs, you can help reduce the risk by tightening the set of types that are executable by sysadm_t. You might also want to consider restricting inputs to sysadm_t, e.g. preventing sysadm_t from reading symlinks with non-system types to prevent an admin from following a malicious symlink.
Signature · 8 lines
Stephen Smalley <[email protected]> National Security Agency -- 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 3 lines · Stephen Smalley
consider restricting inputs to
sysadm_t, e.g. preventingsysadm_tfrom reading symlinks with non-system types to prevent an admin from following a malicious symlink.
The problem with restricting sym-link access is that lnk_file read access is required by ls to show where the link points to! Preventing a sym-link race condition from making "cat something > /tmp/foo" by the administrator become "cat something > /etc/passwd" would be good, but if it means that "ls -l /tmp/foo" can't discover where the link points to (and therefore what the user is doing) then it's very inconvenient.
We could have a separate domain sysadm_ls_t which can getattr on all files and { getattr read } on all lnk_files, but then we have issues of "ls -l > file" not working (and solving this is then a regression).
Unless we can have the kernel recognise readlink(2) as different from doing an open(2) which just happens to follow a sym-link then I don't think we can implement a painless solution to this problem.
Signature · 9 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 · Stephen Smalley
Quoted 4 lines · Chris PeBenito
One thing that hasn't sat well with me for a long time is that just about all
file_typesare sysadmfile in the strict policy. To me, this sounds like an excessive amount of access forsysadm_t(with exception of theunrestricted_admintunable being on).
[cut]
Quoted 3 lines
A commendable goal, but you need to gradually migrate toward such a scheme, as existing usage assumes direct access by admins running common utilities, using shell redirection, etc.
How does not being able to write to bin_t files, for example, break the existing usage?
Signature · 8 lines
Chris PeBenito <[email protected]> Developer, Hardened Gentoo Linux Embedded Gentoo Linux Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243 Key fingerprint = B0E6 877A 883F A57A 8E6A CB00 BC8E E42D E6AF 9243
Quoted 2 lines · Chris PeBenito
How does not being able to write to
bin_tfiles, for example, break the existing usage?
"Existing usage" includes the idea that these "should work":
# dmesg > /tmp/foo
or
# vi /etc/hosts
I'm sure that you can come up with kajillions of similar examples of things that Unixoid sysadmins have been expecting they can do with just shell redirects, awk, grep, and a text editor, and been having them actually work for the last 25 years.
That's a lot of inertia.... ;)
Quoted 5 lines · On Sun, 2004-06-13 at 19:51, [email protected] wrote:
Quoted 2 lines · Chris PeBenito
How does not being able to write to
bin_tfiles, for example, break the existing usage?
Quoted 7 lines
"Existing usage" includes the idea that these "should work":
# dmesg > /tmp/fooor
# vi /etc/hosts
I don't see how these would be broken. Admin_domain() has tmp_domain(), so /tmp/foo will be writable. I'm not arguing that sysadmfile should be eliminated, just reduced; /etc/hosts would still be a sysadmfile, and therefore be writable.
Signature · 8 lines
Chris PeBenito <[email protected]> Developer, Hardened Gentoo Linux Embedded Gentoo Linux Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243 Key fingerprint = B0E6 877A 883F A57A 8E6A CB00 BC8E E42D E6AF 9243
Quoted 4 lines · Chris PeBenito
I don't see how these would be broken.
Admin_domain()hastmp_domain(), so/tmp/foowill be writable. I'm not arguing that sysadmfile should be eliminated, just reduced;/etc/hostswould still be a sysadmfile, and therefore be writable.
Doing:
vi /bin/my-script
Then adding a cron entry to run /bin/my-script is fairly common sysadmin practise. It's probably a bad idea, but it's what almost everyone does.
Signature · 9 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 4 lines · Chris PeBenito
I don't see how these would be broken.
Admin_domain()hastmp_domain(), so/tmp/foowill be writable. I'm not arguing that sysadmfile should be eliminated, just reduced;/etc/hostswould still be a sysadmfile, and therefore be writable.
OK.. So pick *any* *other* file that fills these requirements:
1) You're proposing that the file in question not be a sysadmfile anymore.
2) People have been known to edit said file with a text editor.