CVE 2019-14287

https://thehackernews.com/2019/10/linux-sudo-run-as-root-flaw.html

Affected version of sudo: 

Machine generated alternative text:
sudo -V 
Sudo version 1.8.27

And before

For this exploit to demonstrate I’ll make a new user on my box and name it temp

C:\CA2AEB25\FBB151FC-59B1-4916-937F-BB333D5CA498_files\image002.png

After setting the account up, let’s make sure it is restricted to run commands as root on the box. Test this by trying to execute `sudo -u root id`. 

Sidenote: If the command succeeds then the configuration is not yet in place and the user has no restrictions on their sudo. for the exploit to be applicable we have to enable these restrictions. you can see config file more below

Machine generated alternative text:
su temp 
sudo id 
sorry, user temp is not allowed to execute ' / usr/bin/id' as root on rival.

So as we can see here the temp user cannot run the id command as root.

Let’s see how this is defined in our sudo config file

By entering ‘visudo’ (run-as root!) we can edit the restrictions on sudo

Machine generated alternative text:
This file MUST be edited with the 'visudo' command as root. 
Please consider adding local content in /etc/sudoers.d/ instead of 
directly modifying this file. 
See the man page for details on how to write a sudoers file. 
Defaults 
Defaults 
Defaults 
# Host 
# Cmnd 
root 
temp 
alias 
alias 
alias 
env reset 
mail_badpass 
/us r/ local/sbin: /us r/ local/bin : / us r/ sbin: /us r/bin : /sbin : /bin" 
specification 
specification 
specification 
privilege specification 
ALL 
! root) ALL 
# Allow members of group sudo to execute 
%sudo ALL 
# See sudoers (5) for more information on 
" /etc/sudoers. tmp" 28L, 696C 
any command 
"#include" directives: 
21,25-28 
TOP
sudo config file

‘temp ALL=(ALL, !root) ALL’ is the one we’re looking for.
this rule implies that temp user can run sudo as any user on the system except for root (defined by !root, means litteraly “NOT root”). the ‘ALL’ value at the end implies that every command can be sudo’d but again, not as the root user.

Let’s see some examples

So the first command shows us the user we are at that moment: ‘temp’

when we try to get that command ran elevated (as root) we get an error because we specified that in our rules.

Instead of specifying the run-as user with the name we can use -u#<id> to do so. now if we try an invalid ID for user we can bypass the rule on root user. that’s because root will always be ID 0 and if we take -1 or 4294967295 as ID then it returns a value 0 and thus root ID. this one bypasses the rule we applied and gets executed anyway. see screenshot above

now we can use that to turn a shell as normal user into root shell with only the password of user.
example given in next screen shot

And we got root rights. Simple as that

One thought on “CVE 2019-14287”

Leave a comment