CVE-2022-1720 - Buffer Over-read

Severity

78%

Complexity

18%

Confidentiality

98%

Buffer Over-read in function grab_file_name in GitHub repository vim/vim prior to 8.2.4956. This vulnerability is capable of crashing the software, memory modification, and possible remote execution.

CVSS 3.1 Base Score 7.8. CVSS Attack Vector: local. CVSS Attack Complexity: low. CVSS Vector: (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

CVSS 2.0 Base Score 6.8. CVSS Attack Vector: network. CVSS Attack Complexity: medium. CVSS Vector: (AV:N/AC:M/Au:N/C:P/I:P/A:P).

Demo Examples

Buffer Over-read

CWE-126

In the following C/C++ example the method processMessageFromSocket() will get a message from a socket, placed into a buffer, and will parse the contents of the buffer into a structure that contains the message length and the message body. A for loop is used to copy the message body into a local character string which will be passed to another method for processing.


               
}
return success;// get message from socket and store into buffer//Ignoring possibliity that buffer > BUFFER_SIZE
success = processMessage(message);// place contents of the buffer into message structure// copy message body into string for processing
message[index] = msg->msgBody[index];
// process message

However, the message length variable from the structure is used as the condition for ending the for loop without validating that the message length variable accurately reflects the length of message body. This can result in a buffer over read by reading from memory beyond the bounds of the buffer if the message length variable indicates a length that is longer than the size of a message body (CWE-130).

Buffer Over-read

CWE-126

The following C/C++ example demonstrates a buffer over-read due to a missing NULL terminator. The main method of a pattern matching utility that looks for a specific pattern within a specific file uses the string strncopy() method to copy the command line user input file name and pattern to the Filename and Pattern character arrays respectively.


               
}
Scan_File(Filename, Pattern);/* Validate number of parameters and ensure valid content *//* copy filename parameter to variable, may cause off-by-one overflow *//* copy pattern parameter to variable, may cause off-by-one overflow */

However, the code do not take into account that strncpy() will not add a NULL terminator when the source buffer is equal in length of longer than that provide size attribute. Therefore if a user enters a filename or pattern that are the same size as (or larger than) their respective character arrays, a NULL terminator will not be added (CWE-170) which leads to the printf() read beyond the expected end of the Filename and Pattern buffers.

To fix this problem, be sure to subtract 1 from the sizeof() call to allow room for the null byte to be added.

Pattern[31]='\0';
strncpy(Pattern, argv[3], sizeof(Pattern)-1);/* copy filename parameter to variable, no off-by-one overflow *//* copy pattern parameter to variable, no off-by-one overflow */

Demo Examples

Out-of-bounds Read

CWE-125

In the following code, the method retrieves a value from an array at a specific array index location that is given as an input parameter to the method


               
}
return value;// check that the array index is less than the maximum// length of the array
value = array[index];// get the value at the specified index of the array
// if array index is invalid then output error message// and return value indicating error
value = -1;

However, this method only verifies that the given array index is less than the maximum length of the array but does not check for the minimum value (CWE-839). This will allow a negative value to be accepted as the input array index, which will result in a out of bounds read (CWE-125) and may allow access to sensitive memory. The input array index should be checked to verify that is within the maximum and minimum range required for the array (CWE-129). In this example the if statement should be modified to include a minimum range check, as shown below.


               
...// check that the array index is within the correct// range of values for the array

Overview

First reported 2 years ago

2022-06-20 15:15:00

Last updated 2 years ago

2022-12-08 19:58:00

Affected Software

Debian Linux 9.0

9.0

References

https://github.com/vim/vim/commit/395bd1f6d3edc9f7edb5d1f2d7deaf5a9e3ab93c

https://huntr.dev/bounties/5ccfb386-7eb9-46e5-98e5-243ea4b358a8

[debian-lts-announce] 20220620 [SECURITY] [DLA 3053-1] vim security update

https://github.com/vim/vim/commit/395bd1f6d3edc9f7edb5d1f2d7deaf5a9e3ab93c

Patch, Third Party Advisory

https://huntr.dev/bounties/5ccfb386-7eb9-46e5-98e5-243ea4b358a8

Exploit, Patch, Third Party Advisory

[debian-lts-announce] 20220620 [SECURITY] [DLA 3053-1] vim security update

Mailing List, Third Party Advisory

FEDORA-2022-719f3ec21b

FEDORA-2022-bb7f3cacbf

GLSA-202208-32

FEDORA-2022-719f3ec21b

Mailing List, Third Party Advisory

FEDORA-2022-bb7f3cacbf

Mailing List, Third Party Advisory

GLSA-202208-32

Third Party Advisory

https://support.apple.com/kb/HT213488

https://support.apple.com/kb/HT213443

https://support.apple.com/kb/HT213444

20221030 APPLE-SA-2022-10-27-5 Additional information for APPLE-SA-2022-10-24-2 macOS Ventura 13

20221030 APPLE-SA-2022-10-24-2 macOS Ventura 13

20221030 APPLE-SA-2022-10-27-7 Additional information for APPLE-SA-2022-09-12-4 macOS Monterey 12.6

20221030 APPLE-SA-2022-10-27-9 Additional information for APPLE-SA-2022-09-12-3 macOS Big Sur 11.7

https://support.apple.com/kb/HT213488

Third Party Advisory

https://support.apple.com/kb/HT213443

Third Party Advisory

https://support.apple.com/kb/HT213444

Third Party Advisory

20221030 APPLE-SA-2022-10-27-5 Additional information for APPLE-SA-2022-10-24-2 macOS Ventura 13

Mailing List, Third Party Advisory

20221030 APPLE-SA-2022-10-24-2 macOS Ventura 13

Mailing List, Third Party Advisory

20221030 APPLE-SA-2022-10-27-7 Additional information for APPLE-SA-2022-09-12-4 macOS Monterey 12.6

Mailing List, Third Party Advisory

20221030 APPLE-SA-2022-10-27-9 Additional information for APPLE-SA-2022-09-12-3 macOS Big Sur 11.7

Mailing List, Third Party Advisory

[debian-lts-announce] 20221108 [SECURITY] [DLA 3182-1] vim security update

[debian-lts-announce] 20221108 [SECURITY] [DLA 3182-1] vim security update

Mailing List, Third Party Advisory

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.