You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Worawit Wangwarunyoo bcf829627e
Merge pull request #12 from saidelike/main
2 years ago
asm Initial upload 2 years ago
gdb Initial upload 2 years ago
LICENSE Add a BSD 3-clause license 2 years ago typo 2 years ago typo and comments 2 years ago make defaults mailer exploit more robust and work on Photon OS 3.0 / vCenter Server 7.0 2 years ago fixed patch checking on openSUSE 2 years ago wrong requirement 2 years ago typo and comments 2 years ago forgot create_libx function 2 years ago wrong requirement 2 years ago
exploit_timestamp_race.c add >=2 CPU in requirement 2 years ago forgot masking coredump flag from exit status when bruteforcing 2 years ago

CVE-2021-3156 (Sudo Baron Samedit)

This repository is CVE-2021-3156 exploit targeting Linux x64. For writeup, please visit
Credit to Braon Samedit of Qualys for the original advisory.


Exploit on glibc with tcache
  • auto detect all requirements and number of entries in /etc/nsswitch.conf
  • simplified version of for better exploit understanding
  • exploit_timestamp_race.c overwrite def_timestamp and race condition to modify /etc/passwd
Exploit on glibc without tcache
  • the exploit overwrite struct defaults to modify mailer binary path. It requires sudo compiled without disable-root-mailer such as CentOS 6 and 7.
  • the exploit overwrite struct userspec to bypass authentication and add a new user in /etc/passwd. Support only sudo version 1.8.9-1.8.23.
  • simplified version of for understanding but target only CentOS 7 with default configuration
  • overwrite struct service_user on Debian 9 but support only default /etc/nsswith.conf
  • overwrite struct service_user on Ubuntu 16.04 but support only default /etc/nsswith.conf
  • overwrite struct service_user on Ubuntu 14.04 but support only default /etc/nsswith.conf
  • asm/ tinyelf library and executable for embedded in python exploit
  • gdb/ scripts that used for debugging sudo heap

Choosing exploit

For Linux distributions that glibc has tcache support and enabled (CentOS 8, Ubuntu >= 17.10, Debian 10):

  • try first
  • If an error is not glibc tcache related, you can try exploit_timestamp_race.c next

For Linux distribution that glibc has no tcache support:

  • if a target is Debian 9, Ubuntu 16.04, or Ubuntu 14.04, try for specific version first
  • next, try If you know a target sudo is compiled with --disable-root-mailer, you can skip this exploit. The exploit attempt to check root mailer flag from sudo binary. But sudo permission on some Linux distribution is 4711 (-rws--x--x) which is impossible to check on target system. (Known work OS is CentOS 6 and 7)
  • last, try