busybox wrapper rough design
busybox is a program that contains dozens of utilities in cut-down form. A typical compile will have init, getty, ps, ls, ping, and much more.
This makes things difficult when using SE Linux as several of those programs would normally have different types to trigger automatic domain transition rules.
So I am writing a bbwrap program which runs in it's own domain and can transition to ping_t, getty_t, login_t, etc when running busybox_t.
The bbwrap program does the following:
1) Check argv[0] and make sure it's an absolute or relative path (IE it contains an absolute or relative path.
2) lstat_secure(argv[0]) to determine the type of the link.
3) Determine it's parent domain via getosecsid().
4) Read it's config file which is something like the following. The first field is the parent SID, the second is the type of the link, the third is the domain to transition to, and the fourth is the program to run. user_t ping_exec_t ping_t /bin/busyboxsysadm_t ping_exec_t ping_t /bin/busybox
So if user_t runs bbwrap with an argv[0] of a symlink that has type ping_exec_t then it will mean to run /bin/busybox with argv[0] of "ping" in domain ping_t.
5) Check whether the type of the link would be a suitable entry point for the target domain if it was a file. In this example ping_t can be entered via ping_exec_t so it's OK.
6) Use execve_secure() to run the program with argv[0] being the basename(1) of the original argv[0], the filename being the fourth parameter of the config file, and the context being the original context with the domain changed to the target domain.
Now if you can create a symlink of the appropriate type or a hard link to such a symlink then it is assumed that you are authorised for controlling which programs enter the domain in question (just as if you could create a file of the type in question on a regular SE Linux setup). A correct SE policy prevents unauthorized users from doing such things (and if it doesn't then it's exploitable anyway).
The issue is, can someone trick such a wrapper program into thinking that it's run with a link named "sh" while it's running a link with type init_exec_t?
I welcome any comments on or off list. I plan to publish this program in a couple of days...
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.