modules/exploits/linux/local/cve_2022_0847_dirtypipe.rb
Method initialize
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Dirty Pipe Local Privilege Escalation via CVE-2022-0847',
Method exploit
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def exploit
suid_binary_path = datastore['SUID_BINARY_PATH']
fail_with(Failure::BadConfig, 'The suid binary was not found; try setting SUID_BINARY_PATH') if suid_binary_path.nil?
fail_with(Failure::BadConfig, "The #{suid_binary_path} binary setuid bit is not set") unless setuid?(suid_binary_path)
Method exploit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def exploit
suid_binary_path = datastore['SUID_BINARY_PATH']
fail_with(Failure::BadConfig, 'The suid binary was not found; try setting SUID_BINARY_PATH') if suid_binary_path.nil?
fail_with(Failure::BadConfig, "The #{suid_binary_path} binary setuid bit is not set") unless setuid?(suid_binary_path)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def check
arch = kernel_arch
unless live_compile? || arch.include?('x64') || arch.include?('aarch64') || arch.include?('x86') || arch.include?('armle')
return CheckCode::Safe("System architecture #{arch} is not supported without live compilation")
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
Open
if kernel_version < Rex::Version.new('5.8') ||
kernel_version >= Rex::Version.new('5.16.11') ||
(kernel_version >= Rex::Version.new('5.15.25') && kernel_version < Rex::Version.new('5.16')) ||
(kernel_version >= Rex::Version.new('5.10.102') && kernel_version < Rex::Version.new('5.11'))
return CheckCode::Safe("Linux kernel version #{kernel_version} is not vulnerable")