|
Message-ID: <20150526135946.GE4203@chaz.gmail.com> Date: Tue, 26 May 2015 14:59:46 +0100 From: Stephane Chazelas <stephane.chazelas@...il.com> To: oss-security@...ts.openwall.com Subject: Re: hwclock(8) SUID privilege escalation 2015-05-26 12:47:47 +0200, up201407890@...nos.dcc.fc.up.pt: [...] > Please note that this is possible on Debian-derived (and therefore Ubuntu), > because /bin/sh is provided by dash which does NOT make use > of privmode (does not drop privileges if ruid != euid, unlike bash), > which is a very stupid idea. > > privmode is surprisingly effective at mitigating some common vulnerability > classes and misconfigurations, and it has been around since mid 90's. > Indeed, Chet Ramey (bash author and maintainer) explains that the > purpose of this is to prevent "bogus system(3)/popen(3) calls in > setuid executables" [...] No, bash does NOT drop privileges if ruid != euid when called as sh either . If it were, it would break those commands that use system()/popen() from suid/sgid executables (which arguably they shouldn't be doing) and expect the euid/egid to be preserved. $ ls -ln env sh -rwsr-x--- 1 0 1000 27232 Nov 27 12:00 env* lrwxrwxrwx 1 1000 1000 9 May 26 14:51 sh -> /bin/bash* $ ./env bash -c 'id -u' 1000 $ ./env ./sh -c 'id -u' 0 It does however a mode in which the environment is not trusted as much (for instance exported functions, PS4... are ignored). PATH is still trusted and it's the responsibility of the caller to sanitise it. That's what the "privmode" is: when bash is priviledged, it's more careful. That's not specific to bash, that's in most shells. The difference with bash is that when not called as sh, you have to call bash with -p for that priviledged mode to be enabled (otherwise, bash drops privileges (and the privileged mode is not enabled since you're no longer privileged)). -- Stephane
Powered by blists - more mailing lists
Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.