CVE-2018-18311 - Improper Restriction of Operations within the Bounds of a Memory Buffer

Severity

75%

Complexity

99%

Confidentiality

106%

Perl before 5.26.3 and 5.28.x before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

Perl before 5.26.3 and 5.28.x before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVSS 3.0 Base Score 9.8. CVSS Attack Vector: network. CVSS Attack Complexity: low. CVSS Vector: (CVSS:3.0/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

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

This example takes an IP address from a user, verifies that it is well formed and then looks up the hostname and copies it into a buffer.


               
}
strcpy(hostname, hp->h_name);/*routine that ensures user_supplied_addr is in the right format for conversion */

This function allocates a buffer of 64 bytes to store the hostname, however there is no guarantee that the hostname will not be larger than 64 bytes. If an attacker specifies an address which resolves to a very large hostname, then we may overwrite sensitive data or even relinquish control flow to the attacker.

Note that this example also contains an unchecked return value (CWE-252) that can lead to a NULL pointer dereference (CWE-476).

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

This example applies an encoding procedure to an input string and stores it into a buffer.


               
}
return dst_buf;
die("user string too long, die evil hacker!");
else dst_buf[dst_index++] = user_supplied_string[i];
dst_buf[dst_index++] = ';';
/* encode to < */

The programmer attempts to encode the ampersand character in the user-controlled string, however the length of the string is validated before the encoding procedure is applied. Furthermore, the programmer assumes encoding expansion will only expand a given character by a factor of 4, while the encoding of the ampersand expands by 5. As a result, when the encoding procedure expands the string it is possible to overflow the destination buffer if the attacker provides a string of many ampersands.

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

The following example asks a user for an offset into an array to select an item.


               
}
printf("You selected %s\n", items[index-1]);

The programmer allows the user to specify which element in the list to select, however an attacker can provide an out-of-bounds offset, resulting in a buffer over-read (CWE-126).

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

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

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

Windows provides the _mbs family of functions to perform various operations on multibyte strings. When these functions are passed a malformed multibyte string, such as a string containing a valid leading byte followed by a single null byte, they can read or write past the end of the string buffer causing a buffer overflow. The following functions all pose a risk of buffer overflow: _mbsinc _mbsdec _mbsncat _mbsncpy _mbsnextc _mbsnset _mbsrev _mbsset _mbsstr _mbstok _mbccpy _mbslen

Overview

First reported 6 years ago

2018-12-07 21:29:00

Last updated 5 years ago

2019-07-16 17:15:00

Affected Software

Perl

Canonical Ubuntu Linux 12.04 ESM (Extended Security Maintenance)

12.04

Canonical Ubuntu Linux 14.04 LTS (Long-Term Support)

14.04

Canonical Ubuntu Linux 16.04 LTS (Long-Term Support)

16.04

Canonical Ubuntu Linux 18.04 LTS Edition

18.04

Canonical Ubuntu Linux 18.10

18.10

Debian Linux 8.0 (Jessie)

8.0

Debian Linux 9.0

9.0

NetApp E-Series SANtricity OS Controller

Red Hat OpenShift Container Platform 3.11

3.11

Red Hat Enterprise Linux 6.0

6.0

Red Hat Enterprise Linux (RHEL) 7.0 (7)

7.0

Red Hat Enterprise Linux 7.4

7.4

Red Hat Enterprise Linux 7.5

7.5

Red Hat Enterprise Linux 7.6

7.6

RedHat Enterprise Linux Desktop 7.0

7.0

Red Hat Enterprise Linux Extended Update Support (EUS) 7.6

7.6

RedHat Enterprise Linux Server 7.0

7.0

Red Hat Enterprise Linux Server Advanced mission critical Update Support (AUS) 7.6

7.6

Red Hat Enterprise Linux Server Telecommunications Update Service (TUS) 7.6

7.6

RedHat Enterprise Linux Workstation 7.0

7.0

Apple Mac OS X

Fedora 29

29

References

20190326 APPLE-SA-2019-3-25-2 macOS Mojave 10.14.4, Security Update 2019-002 High Sierra, Security Update 2019-002 Sierra

Mailing List, Third Party Advisory

106145

Third Party Advisory, VDB Entry

1042181

Third Party Advisory, VDB Entry

RHBA-2019:0327

Third Party Advisory

RHSA-2019:0001

Third Party Advisory

RHSA-2019:0010

Third Party Advisory

RHSA-2019:0109

Third Party Advisory

RHSA-2019:1790

RHSA-2019:1942

RHSA-2019:2400

https://bugzilla.redhat.com/show_bug.cgi?id=1646730

Issue Tracking, Patch, Third Party Advisory

https://github.com/Perl/perl5/commit/34716e2a6ee2af96078d62b065b7785c001194be

Patch, Third Party Advisory

https://kc.mcafee.com/corporate/index?page=content&id=SB10278

Third Party Advisory

[debian-lts-announce] 20181130 [SECURITY] [DLA 1601-1] perl security update

Mailing List, Third Party Advisory

FEDORA-2018-9dbe983805

Product, Release Notes

https://metacpan.org/changes/release/SHAY/perl-5.26.3

Third Party Advisory

https://metacpan.org/changes/release/SHAY/perl-5.28.1

Third Party Advisory

https://rt.perl.org/Ticket/Display.html?id=133204

Issue Tracking, Third Party Advisory

20190326 APPLE-SA-2019-3-25-2 macOS Mojave 10.14.4, Security Update 2019-002 High Sierra, Security Update 2019-002 Sierra

Mailing List, Third Party Advisory

GLSA-201909-01

https://security.netapp.com/advisory/ntap-20190221-0003/

Third Party Advisory

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

Third Party Advisory

USN-3834-1

Third Party Advisory

USN-3834-2

Third Party Advisory

DSA-4347

Third Party Advisory

N/A

https://www.oracle.com/technetwork/security-advisory/cpujul2019-5072835.html

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.