CVE-2014-6277 - Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

Severity

99%

Complexity

99%

Confidentiality

165%

GNU Bash through 4.3 bash43-026 does not properly parse function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code or cause a denial of service (uninitialized memory access, and untrusted-pointer read and write operations) via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution. NOTE: this vulnerability exists because of an incomplete fix for CVE-2014-6271 and CVE-2014-7169.

GNU Bash through 4.3 bash43-026 does not properly parse function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code or cause a denial of service (uninitialized memory access, and untrusted-pointer read and write operations) via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution. NOTE: this vulnerability exists because of an incomplete fix for CVE-2014-6271 and CVE-2014-7169.

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 Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

This example code intends to take the name of a user and list the contents of that user's home directory. It is subject to the first variant of OS command injection.


               
system($command);

The $userName variable is not checked for malicious input. An attacker could set the $userName variable to an arbitrary OS command such as:


               
;rm -rf /

Which would result in $command being:


               
ls -l /home/;rm -rf /

Since the semi-colon is a command separator in Unix, the OS would first execute the ls command, then the rm command, deleting the entire file system.

Also note that this example code is vulnerable to Path Traversal (CWE-22) and Untrusted Search Path (CWE-426) attacks.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

This example is a web application that intends to perform a DNS lookup of a user-supplied domain name. It is subject to the first variant of OS command injection.


               
}
close($fh);
print "<br>\n";

Suppose an attacker provides a domain name like this:


               
cwe.mitre.org%20%3B%20/bin/ls%20-l

The "%3B" sequence decodes to the ";" character, and the %20 decodes to a space. The open() statement would then process a string like this:


               
/path/to/nslookup cwe.mitre.org ; /bin/ls -l

As a result, the attacker executes the "/bin/ls -l" command and gets a list of all the files in the program's working directory. The input could be replaced with much more dangerous commands, such as installing a malicious program on the server.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

The example below reads the name of a shell script to execute from the system properties. It is subject to the second variant of OS command injection.


               
System.exec(script);

If an attacker has control over this property, then they could modify the property to point to a dangerous program.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

In the example below, a method is used to transform geographic coordinates from latitude and longitude format to UTM format. The method gets the input coordinates from a user through a HTTP request and executes a program local to the application server that performs the transformation. The method passes the latitude and longitude coordinates as a command-line option to the external program and will perform some processing to retrieve the results of the transformation and return the resulting UTM coordinates.


               
}
return utmCoords;
// process results of coordinate transform// ...

However, the method does not verify that the contents of the coordinates input parameter includes only correctly-formatted latitude and longitude coordinates. If the input coordinates were not validated prior to the call to this method, a malicious user could execute another program local to the application server by appending '&' followed by the command for another program to the end of the coordinate string. The '&' instructs the Windows operating system to execute another program.

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-78

The following code is from an administrative web application designed to allow users to kick off a backup of an Oracle database using a batch-file wrapper around the rman utility and then run a cleanup.bat script to delete some temporary files. The script rmanDB.bat accepts a single command line parameter, which specifies what type of backup to perform. Because access to the database is restricted, the application runs the backup as a privileged user.


               
...
"&&c:\\utl\\cleanup.bat\"")

The problem here is that the program does not do any validation on the backuptype parameter read from the user. Typically the Runtime.exec() function will not execute multiple commands, but in this case the program first runs the cmd.exe shell in order to run multiple commands with a single call to Runtime.exec(). Once the shell is invoked, it will happily execute multiple commands separated by two ampersands. If an attacker passes a string of the form "& del c:\\dbms\\*.*", then the application will execute this command along with the others specified by the program. Because of the nature of the application, it runs with the privileges necessary to interact with the database, which means whatever command the attacker injects will run with those privileges as well.

Overview

Type

GNU Bourne-Again SHellbash (GNU Bash)

First reported 10 years ago

2014-09-27 22:55:00

Last updated 6 years ago

2018-08-09 01:29: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

http://lcamtuf.blogspot.com/2014/09/bash-bug-apply-unofficial-patch-now.html

Exploit, Patch

http://lcamtuf.blogspot.com/2014/10/bash-bug-how-we-finally-cracked.html

http://linux.oracle.com/errata/ELSA-2014-3093

http://linux.oracle.com/errata/ELSA-2014-3094

APPLE-SA-2015-01-27-4

APPLE-SA-2015-09-30-3

SUSE-SU-2014:1287

openSUSE-SU-2014:1310

HPSBGN03138

HPSBHF03125

HPSBMU03143

HPSBMU03144

HPSBST03129

HPSBGN03142

HPSBGN03141

HPSBHF03146

HPSBHF03145

HPSBST03157

HPSBST03155

HPSBMU03165

HPSBST03181

HPSBST03154

HPSBMU03182

HPSBMU03217

SSRT101868

SSRT101830

HPSBMU03245

HPSBMU03246

SSRT101819

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

58200

59907

59961

60024

60034

60044

60055

60063

60193

60325

60433

61065

61128

61129

61283

61287

61291

61312

61313

61328

61442

61471

61485

61503

61550

61552

61565

61603

61633

61641

61643

61654

61703

61780

61816

61857

62312

62343

http://support.apple.com/HT204244

http://support.novell.com/security/cve/CVE-2014-6277.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

USN-2380-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=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=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.