CVE-2020-9866 - Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

Severity

98%

Complexity

39%

Confidentiality

98%

A buffer overflow was addressed with improved bounds checking. This issue is fixed in macOS Catalina 10.15.6, Security Update 2020-004 Mojave, Security Update 2020-004 High Sierra. A buffer overflow may result in arbitrary code execution.

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

CVSS 2.0 Base Score 7.5. CVSS Attack Vector: network. CVSS Attack Complexity: low. CVSS Vector: (AV:N/AC:L/Au:N/C:P/I:P/A:P).

Demo Examples

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

The following code asks the user to enter their last name and then attempts to store the value entered in the last_name array.


               
scanf ("%s", last_name);

The problem with the code above is that it does not restrict or limit the size of the name entered by the user. If the user enters "Very_very_long_last_name" which is 24 characters long, then a buffer overflow will occur since the array can only hold 20 characters total.

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

The following code attempts to create a local copy of a buffer to perform some manipulations to the data.


               
}
...

However, the programmer does not ensure that the size of the data pointed to by string will fit in the local buffer and blindly copies the data with the potentially dangerous strcpy() function. This may result in a buffer overflow condition if an attacker can influence the contents of the string parameter.

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

The excerpt below calls the gets() function in C, which is inherently unsafe.


               
}
...

However, the programmer uses the function gets() which is inherently unsafe because it blindly copies all input from STDIN to the buffer without restricting how much is copied. This allows the user to provide a string that is larger than the buffer size, resulting in an overflow condition.

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

In the following example, a server accepts connections from a client and processes the client request. After accepting a client connection, the program will obtain client information using the gethostbyaddr method, copy the hostname of the client that connected to a local variable and output the hostname of the client to a log file.


               
...
close(serversocket);
}
close(clientsocket);

However, the hostname of the client that connected may be longer than the allocated size for the local hostname variable. This will result in a buffer overflow when copying the client hostname to the local variable using the strcpy method.

Overview

First reported 4 years ago

2020-10-27 21:15:00

Last updated 4 years ago

2020-10-29 20:24:00

Affected Software

Apple Mac OS X

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.