Skip to contentSkip to conversation

Small patch for runuser: disallow suid operation

PATCH Thomas Bleher 2 participants 3 messages Oct 19, 2005 – Nov 14, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

I think the following small patch should be applied to the coreutils package, on top of the existing patch:

runuser.c renamed from runuser.c.orig +2 -0
@@ -19,6 +19,8 @@
 	return PAM_SUCCESS;
 }
 int pam_open_session(pam_handle_t *pamh, int flags){
+	if (getuid() != geteuid()) /* safety net: deny operation if we are suid by accident */
+		error(EXIT_FAIL, 1, "runuser may not be setuid");
 	return PAM_SUCCESS;
 }
 int pam_close_session(pam_handle_t *pamh, int flags){

Rationale:
There are still a lot of scripts that assume they can use "su" to switch uids. In some situations (eg mine :) it is simply too much work to audit them all and keep up with updates. Instead I intend to "mv su su2; ln runuser su" and teach the other admins to use su2 instead (users are not allowed to use su anyway). The only problem currently is that if the permissions on the new su are accidently set to the usual values (by admin error or a permission check script) there is a security hole immediately. This small patch prevents this problem; it should not interfere with normal operation in any way.

Thomas

Signature · 2 lines
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7
#1 lore raw
Quoted 2 lines · Thomas Bleher

I think the following small patch should be applied to the coreutils package, on top of the existing patch:

Sounds reasonable to me. Have you filed a bugzilla?

Quoted 11 lines
runuser.c renamed from runuser.c.orig +1 -0
@@ -19,6 +19,8 @@
 	return PAM_SUCCESS;
 }
 int pam_open_session(pam_handle_t *pamh, int flags){
+	if (getuid() != geteuid()) /* safety net: deny operation if we are suid
 by accident */ +		error(EXIT_FAIL, 1, "runuser may not be setuid");
 	return PAM_SUCCESS;
 }
 int pam_close_session(pam_handle_t *pamh, int flags){
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.
#2 lore raw
Quoted 6 lines · Russell Coker
Quoted 2 lines · Thomas Bleher

I think the following small patch should be applied to the coreutils package, on top of the existing patch:

Sounds reasonable to me. Have you filed a bugzilla?

Just filed as
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=173113

Quoted 12 lines
Quoted 11 lines
runuser.c renamed from runuser.c.orig +1 -0
@@ -19,6 +19,8 @@
 	return PAM_SUCCESS;
 }
 int pam_open_session(pam_handle_t *pamh, int flags){
+	if (getuid() != geteuid()) /* safety net: deny operation if we are suid
 by accident */ +		error(EXIT_FAIL, 1, "runuser may not be setuid");
 	return PAM_SUCCESS;
 }
 int pam_close_session(pam_handle_t *pamh, int flags){
Signature · 7 lines
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7

--
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.