-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Adds module for sudo chroot LPE (CVE-2025-32463) #20376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Adds module for sudo chroot LPE (CVE-2025-32463) #20376
Conversation
a9a701f
to
d50644f
Compare
d50644f
to
14fb001
Compare
|
||
return CheckCode::Safe if !file?('/etc/nsswitch.conf') | ||
|
||
sudo_version.gsub!(/p/, '.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a comment here to explain what's going on :)
'Notes' => { | ||
'Stability' => [CRASH_SAFE], | ||
'Reliability' => [REPEATABLE_SESSION], | ||
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of things are logged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, you can add setting to sudo
that will save a log every time you run it along with arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this isn't the default behaviour, so I don't think we should have IOC_IN_LOGS
|
||
cd(temp_dir) | ||
|
||
cmd_exec("mkdir -p #{base_dir}/etc libnss_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd_exec("mkdir -p #{base_dir}/etc libnss_") | |
mkdir("#{base_dir}/etc libnss_") |
Metasploit's (remote) mkdir behaves like mkdir -p
.
execve("#{datastore['WritableDir']}/#{payload_file}",NULL,NULL); /* root shell */ | ||
}> | ||
|
||
upload_and_compile("#{temp_dir}/libnss_/#{lib_filename}.so.2", exploit_code, "-shared -fPIC -Wl,-init,#{base_dir}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any context on why we need to upload and compile our own payload here, I think there's existing payload prepend flags in framework for uid/gid setting - or was chdir
the hard-blocker here 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the payload needs to chdir
to exit from chroot
. That being said, I think the bigger blocker might be the fact that payload needs to act as , the constructor for some reason, so I preferred to compile things on fly. libnss.so
library, so for that reasonBut I'll do some tests, see if it might work without compiling anything. After some tests, it seems like generate_payload_dll
does not do the trick, because the payload needs to run before main
(?), so whatever we want to run, it should be run as init
- __attribute__((constructor))
. I haven't come across such options for metasploit payload, so I left it as it is.
## Vulnerable Application | ||
|
||
|
||
Sudo before version 1.19.17p1 allows user to use `chroot` option, when executing command. The option is intended to run a command with user-selected root directory (if sudoers file allow it). Change in version 1.9.14 allows resolving paths via `chroot` using user-specified root directory when sudoers is still evaluating. This allows the attacker to trick Sudo into loading arbitrary shared object. As target shared object, Name Service Switch (NSS) operations are trigged before resolving sudoers, but after running `chroot` syscall. The module requires existing session and requires compiler on target machine (e.g. `gcc`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worthwhile to explicitly state versions 1.9.14-1.9.17p1 are vulnerable in the first sentence. No one wants to dig to find the second bookend. Ain't nobody got time for that(TM).
require 'pry' | ||
require 'pry-byebug' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be removed
cd6167a
to
8c43583
Compare
This PR adds a local module for CVE-2025-32463 - local privilege escalation in sudo before version 1.9.17p1. The module requires existing session and ability to compile C payload on the target machine.
Vulnerable Application
Sudo before version 1.19.17p1 allows user to use
chroot
option, when executing command. The option is intended to run a command with user-selected root directory (if sudoers file allow it). Change in version 1.9.14 allows resolving paths viachroot
using user-specified root directory when sudoers is still evaluating. This allows the attacker to trick Sudo into loading arbitrary shared object. As target shared object, Name Service Switch (NSS) operations are trigged before resolving sudoers, but after runningchroot
syscall. The module requires existing session and requires compiler on target machine (e.g.gcc
).Installation of vulnerable sudo:
Verification Steps
use linux/local/sudo_chroot_cve_2025_32463
set lhost [attacker IP address]
set lport [attacker port]
run
Options
COMPILE
Option setting if compile target payload on the target.
COMPILER
Option setting the compiler to compile target payload.
Scenarios