CVE-2014-7186 - Improper Restriction of Operations within the Bounds of a Memory Buffer

Severity

99%

Complexity

99%

Confidentiality

165%

The redirection implementation in parse.y in GNU Bash through 4.3 bash43-026 allows remote attackers to cause a denial of service (out-of-bounds array access and application crash) or possibly have unspecified other impact via crafted use of here documents, aka the "redir_stack" issue.

The redirection implementation in parse.y in GNU Bash through 4.3 bash43-026 allows remote attackers to cause a denial of service (out-of-bounds array access and application crash) or possibly have unspecified other impact via crafted use of here documents, aka the "redir_stack" issue.

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

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

Type

GNU Bourne-Again SHellbash (GNU Bash)

First reported 10 years ago

2014-09-28 19:55:00

Last updated 6 years ago

2018-10-09 19:52:00

Affected Software

GNU Bourne-Again SHellbash (GNU Bash) 1.14.0

1.14.0

GNU Bourne-Again SHellbash (GNU Bash) 1.14.1

1.14.1

GNU Bourne-Again SHellbash (GNU Bash) 1.14.2

1.14.2

GNU Bourne-Again SHellbash (GNU Bash) 1.14.3

1.14.3

GNU Bourne-Again SHellbash (GNU Bash) 1.14.4

1.14.4

GNU Bourne-Again SHellbash (GNU Bash) 1.14.5

1.14.5

GNU Bourne-Again SHellbash (GNU Bash) 1.14.6

1.14.6

GNU Bourne-Again SHellbash (GNU Bash) 1.14.7

1.14.7

GNU Bourne-Again SHellbash (GNU Bash) 2.0

2.0

GNU Bourne-Again SHellbash (GNU Bash) 2.01

2.01

GNU Bourne-Again SHellbash (GNU Bash) 2.01.1

2.01.1

GNU Bourne-Again SHellbash (GNU Bash) 2.02

2.02

GNU Bourne-Again SHellbash (GNU Bash) 2.02.1

2.02.1

GNU Bourne-Again SHellbash (GNU Bash) 2.03

2.03

GNU Bourne-Again SHellbash (GNU Bash) 2.04

2.04

GNU Bourne-Again SHellbash (GNU Bash) 2.05

2.05

GNU Bourne-Again SHellbash (GNU Bash) 2.05a

2.05

GNU Bourne-Again SHellbash (GNU Bash) 2.05b

2.05

GNU Bourne-Again SHellbash (GNU Bash) 3.0

3.0

GNU Bourne-Again SHellbash (GNU Bash) 3.0.16

3.0.16

GNU Bourne-Again SHellbash (GNU Bash) 3.1

3.1

GNU Bourne-Again SHellbash (GNU Bash) 3.2

3.2

GNU Bourne-Again SHellbash (GNU Bash) 3.2.48

3.2.48

GNU Bourne-Again SHellbash (GNU Bash) 4.0

4.0

GNU Bourne-Again SHellbash (GNU Bash) 4.0 release candidate 1

4.0

GNU Bourne-Again SHellbash (GNU Bash) 4.1

4.1

GNU Bourne-Again SHellbash (GNU Bash) 4.2

4.2

GNU Bourne-Again SHellbash (GNU Bash) 4.3

4.3

References

JVN#55667175

JVNDB-2014-000126

APPLE-SA-2015-01-27-4

APPLE-SA-2015-09-30-3

openSUSE-SU-2014:1229

openSUSE-SU-2014:1242

SUSE-SU-2014:1247

openSUSE-SU-2014:1254

SUSE-SU-2014:1259

HPSBGN03138

HPSBHF03125

HPSBMU03143

HPSBMU03144

HPSBST03131

HPSBST03129

HPSBGN03142

HPSBGN03141

HPSBST03157

HPSBST03155

HPSBMU03165

HPSBST03181

HPSBST03154

HPSBMU03182

HPSBST03148

HPSBMU03217

SSRT101711

SSRT101868

SSRT101830

HPSBMU03245

HPSBMU03246

SSRT101819

[oss-security] 20140925 Fwd: Non-upstream patches for bash

Exploit

[oss-security] 20140926 Re: Fwd: Non-upstream patches for bash

[oss-security] 20140928 Re: CVE-2014-6271: remote code execution through bash

http://packetstormsecurity.com/files/128517/VMware-Security-Advisory-2014-0010.html

http://packetstormsecurity.com/files/128567/CA-Technologies-GNU-Bash-Shellshock.html

RHSA-2014:1311

RHSA-2014:1312

RHSA-2014:1354

20141001 FW: NEW VMSA-2014-0010 - VMware product updates address critical Bash security vulnerabilities

58200

59907

60024

60034

60044

60055

60063

60193

60433

61065

61128

61129

61188

61283

61287

61291

61312

61313

61328

61442

61471

61479

61485

61503

61550

61552

61565

61603

61618

61622

61633

61636

61641

61643

61654

61703

61711

61780

61816

61873

62228

62312

62343

http://support.apple.com/HT204244

http://support.novell.com/security/cve/CVE-2014-7186.html

20140926 GNU Bash Environment Variable Command Injection Vulnerability

MDVSA-2015:164

http://www.novell.com/support/kb/doc.php?id=7015721

http://www.oracle.com/technetwork/topics/security/bashcve-2014-7169-2317675.html

http://www.qnap.com/i/en/support/con_show.php?cid=61

20141001 NEW VMSA-2014-0010 - VMware product updates address critical Bash security vulnerabilities

USN-2364-1

http://www.vmware.com/security/advisories/VMSA-2014-0010.html

http://www-01.ibm.com/support/docview.wss?uid=isg3T1021272

http://www-01.ibm.com/support/docview.wss?uid=isg3T1021279

http://www-01.ibm.com/support/docview.wss?uid=isg3T1021361

http://www-01.ibm.com/support/docview.wss?uid=ssg1S1004879

http://www-01.ibm.com/support/docview.wss?uid=ssg1S1004897

http://www-01.ibm.com/support/docview.wss?uid=ssg1S1004898

http://www-01.ibm.com/support/docview.wss?uid=ssg1S1004915

http://www-01.ibm.com/support/docview.wss?uid=swg21685541

http://www-01.ibm.com/support/docview.wss?uid=swg21685604

http://www-01.ibm.com/support/docview.wss?uid=swg21685733

http://www-01.ibm.com/support/docview.wss?uid=swg21685749

http://www-01.ibm.com/support/docview.wss?uid=swg21685914

http://www-01.ibm.com/support/docview.wss?uid=swg21686084

http://www-01.ibm.com/support/docview.wss?uid=swg21686131

http://www-01.ibm.com/support/docview.wss?uid=swg21686246

http://www-01.ibm.com/support/docview.wss?uid=swg21686445

http://www-01.ibm.com/support/docview.wss?uid=swg21686447

http://www-01.ibm.com/support/docview.wss?uid=swg21686479

http://www-01.ibm.com/support/docview.wss?uid=swg21686494

http://www-01.ibm.com/support/docview.wss?uid=swg21687079

http://www-947.ibm.com/support/entry/portal/docdisplay?lndocid=MIGR-5096315

https://kb.bluecoat.com/index?page=content&id=SA82

https://kb.juniper.net/InfoCenter/index?page=content&id=JSA10648

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

https://support.apple.com/HT205267

https://support.citrix.com/article/CTX200217

https://support.citrix.com/article/CTX200223

https://support.f5.com/kb/en-us/solutions/public/15000/600/sol15629.html

https://support.hpe.com/hpsc/doc/public/display?docLocale=en_US&docId=emr_na-c04497075

https://support.hpe.com/hpsc/doc/public/display?docLocale=en_US&docId=emr_na-c04518183

https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk102673&src=securityAlerts

https://www.suse.com/support/shellshock/

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.