A vulnerability in SELinux (fwd)
Hello,
Vayne Salomon> 'Sorry about the previously terse note, the version below
Vayne Salomon> was meant to be sent to an internal list first. Bravissimo. Very responsible indeed. Why not to slashdot ?
Brian May> I had a feeling that LD_PRELOAD was somehow ignored if the exec Brian May> would trigger a change in domain?
Obviously it is not. Obviously it should be.
Brian May> Can this be reproduced with 2.4.x?
Yes.
Brian May> What is the label associated with libSegfault.so? Read the advisory, or recall how "make relabel" works.
Brian May> IIRC A process needs exec rights in order to use a shared library. Correct. That is why simple "LD_PRELOAD=./my_evil_library.so schfn" does not work.
Carsten Grohmann> This time I can't reproduce it the in section II Carsten Grohmann> descripted attack.
The ulimit syntax may depend on your bash version; you may have to use "ulimit -s 10".
Russel> Over the last few days on the #selinux list there has been Russel> discussion of these things. The easiest implementation of such an Russel> attack (which was successfully used in practise) was to create a Russel> shell function named newrole() which gets
You mean, alter ~someuser/.bashrc ? At least in my setup (default policy), root:user_r:user_t has no access to ~root.
RW
--
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 6 lines · Rafal Wojtczuk
Russel> Over the last few days on the #selinux list there has been Russel> discussion of these things. The easiest implementation of such an Russel> attack (which was successfully used in practise) was to create a Russel> shell function named
newrole()which gets
You mean, alter ~someuser/.bashrc ? At least in my setup (default policy), root:user_r:user_t has no access to ~root.
If root has dac_override capability then it can over-write the .bashrc.
If you crack sshd then you can login with whichever UID you choose and the ability to write the files in that user's home directory (with the current default policy).
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 6 lines · Rafal Wojtczuk
Russel> Over the last few days on the #selinux list there has been Russel> discussion of these things. The easiest implementation of such an Russel> attack (which was successfully used in practise) was to create a Russel> shell function named
newrole()which gets
You mean, alter ~someuser/.bashrc ? At least in my setup (default policy), root:user_r:user_t has no access to ~root.
not to ~root, because it's labeled as sysadm_home_(dir_)t, but to, say, ~russel or ~tom.
Look back to about monday, where I posted something about this, and the follow ups where it was recreated on the Gentoo play system.
Signature · 8 lines
http://web.lemuria.org/pubkey.html pub 1024D/2D7A04F5 2002-05-16 Tom Vogt <[email protected]> Key fingerprint = C731 64D1 4BCF 4C20 48A4 29B2 BF01 9FA1 2D7A 04F5 -- 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 · Rafal Wojtczuk
Brian May> IIRC A process needs exec rights in order to use a shared library. Correct. That is why simple "LD_PRELOAD=./my_evil_library.so schfn" does not work.
I think the key mistake I made (im my sleep) is that libSegFault.so is a libc6 library (that does what???), and it is installed on all Linux systems.
What is libSegFault.so anyway?
The bug reported here is that any library in /lib can be used in LD_PRELOAD. This would appear to be a potential problem for any exec from a "untrusted" domain that changes the domain to one that grants more access, not just schfn.
You could relabel every library, and only allow domains to execute libraries that are required by the application, but unless this can be automatated or semiautomated to some degree (eg. by looking at output of ldd), I think this could be a tedious and error prone task.
Then you have issues that program X runs in a new domain, and may not require library Z, but execs program Y in the same domain which does require Z.
You could make every program that changes the domain statically linked, but that would be painful.
You could remove every domain switch from an "untrusted" domain to a domain with more access and replace them with communications to a trusted process, I think this would be a lot of work (just how many times does this occur anyway? Maybe some sort of tool to automatically count this would be useful...). I think this would be an interesting ideal all the same, but outside the scope of SE-Linux.
Which leaves the one last option: modifying /lib/ld-linux.so.2 to ignore LD_PRELOAD if the domain has changed.
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 8 lines · Brian May
You could relabel every library, and only allow domains to execute libraries that are required by the application, but unless this can be automatated or semiautomated to some degree (eg. by looking at output of ldd), I think this could be a tedious and error prone task.
Then you have issues that program X runs in a new domain, and may not require library Z, but execs program Y in the same domain which does require Z.
Despite the potential difficulties, I'd still recommend partitioning the shared libraries into multiple types and limiting especially privileged domains to a subset of the complete set of shared library types. Given a small set of privileged domains (and a small set of code that needs to run in those domains), this should be feasible.
Quoted 2 lines
Which leaves the one last option: modifying
/lib/ld-linux.so.2to ignoreLD_PRELOADif the domain has changed.
Yes, changing ld.so to clear the sensitive LD_* vars on SID/context transitions is desirable. We could also provide a kernel mechanism for doing a complete purge/reset of the environment on certain SID/context transitions, but that would be far less fine-grained.
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.