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

Severity

98%

Complexity

39%

Confidentiality

98%

GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code 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, aka "ShellShock." NOTE: the original fix for this issue was incorrect; CVE-2014-7169 has been assigned to cover the vulnerability that is still present after the incorrect fix.

GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code 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, aka "ShellShock." NOTE: the original fix for this issue was incorrect; CVE-2014-7169 has been assigned to cover the vulnerability that is still present after the incorrect fix.

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 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-24 18:48:00

Last updated 5 years ago

2019-10-09 23:11: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

http://advisories.mageia.org/MGASA-2014-0388.html

Third Party Advisory

APPLE-SA-2014-10-16-1

Third Party Advisory

JVN#55667175

Vendor Advisory

JVNDB-2014-000126

Third Party Advisory, VDB Entry, Vendor Advisory

http://kb.juniper.net/InfoCenter/index?page=content&id=JSA10673

Third Party Advisory

http://lcamtuf.blogspot.com/2014/09/quick-notes-about-bash-bug-its-impact.html

Third Party Advisory

http://linux.oracle.com/errata/ELSA-2014-1293.html

Third Party Advisory

http://linux.oracle.com/errata/ELSA-2014-1294.html

Third Party Advisory

SUSE-SU-2014:1212

Third Party Advisory

SUSE-SU-2014:1213

Third Party Advisory

SUSE-SU-2014:1223

Third Party Advisory

openSUSE-SU-2014:1226

Third Party Advisory

openSUSE-SU-2014:1238

Third Party Advisory

openSUSE-SU-2014:1254

Third Party Advisory

SUSE-SU-2014:1260

Third Party Advisory

SUSE-SU-2014:1287

Third Party Advisory

openSUSE-SU-2014:1308

Third Party Advisory

openSUSE-SU-2014:1310

Third Party Advisory

HPSBGN03117

Third Party Advisory

HPSBHF03119

Third Party Advisory

HPSBHF03124

Third Party Advisory

HPSBST03122

Third Party Advisory

HPSBMU03133

Third Party Advisory

HPSBGN03138

Third Party Advisory

HPSBHF03125

Third Party Advisory

HPSBMU03143

Third Party Advisory

HPSBMU03144

Third Party Advisory

HPSBST03131

Third Party Advisory

HPSBST03129

Third Party Advisory

HPSBGN03142

Third Party Advisory

HPSBGN03141

Third Party Advisory

HPSBHF03146

Third Party Advisory

HPSBHF03145

Third Party Advisory

HPSBST03157

Third Party Advisory

HPSBST03155

Third Party Advisory

HPSBMU03165

Third Party Advisory

HPSBST03181

Third Party Advisory

HPSBST03154

Third Party Advisory

HPSBMU03182

Third Party Advisory

HPSBST03148

Third Party Advisory

HPSBMU03217

Third Party Advisory

SSRT101711

Third Party Advisory

SSRT101868

Third Party Advisory

HPSBMU03245

Third Party Advisory

HPSBMU03246

Third Party Advisory

HPSBST03265

Third Party Advisory

SSRT101816

Third Party Advisory

SSRT101819

Third Party Advisory

HPSBST03195

Third Party Advisory

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

Third Party Advisory, VDB Entry

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

Third Party Advisory, VDB Entry

http://packetstormsecurity.com/files/128573/Apache-mod_cgi-Remote-Command-Execution.html

Third Party Advisory, VDB Entry

http://packetstormsecurity.com/files/137376/IPFire-Bash-Environment-Variable-Injection-Shellshock.html

Exploit, Third Party Advisory, VDB Entry

RHSA-2014:1293

Third Party Advisory

RHSA-2014:1294

Third Party Advisory

RHSA-2014:1295

Third Party Advisory

RHSA-2014:1354

Third Party Advisory

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

Mailing List, Third Party Advisory

58200

Third Party Advisory

59272

Third Party Advisory

59737

Third Party Advisory

59907

Third Party Advisory

60024

Third Party Advisory

60034

Third Party Advisory

60044

Third Party Advisory

60055

Third Party Advisory

60063

Third Party Advisory

60193

Third Party Advisory

60325

Third Party Advisory

60433

Third Party Advisory

60947

Third Party Advisory

61065

Third Party Advisory

61128

Third Party Advisory

61129

Third Party Advisory

61188

Third Party Advisory

61283

Third Party Advisory

61287

Third Party Advisory

61291

Third Party Advisory

61312

Third Party Advisory

61313

Third Party Advisory

61328

Third Party Advisory

61442

Third Party Advisory

61471

Third Party Advisory

61485

Third Party Advisory

61503

Third Party Advisory

61542

Third Party Advisory

61547

Third Party Advisory

61550

Third Party Advisory

61552

Third Party Advisory

61565

Third Party Advisory

61603

Third Party Advisory

61633

Third Party Advisory

61641

Third Party Advisory

61643

Third Party Advisory

61654

Third Party Advisory

61676

Third Party Advisory

61700

Third Party Advisory

61703

Third Party Advisory

61711

Third Party Advisory

61715

Third Party Advisory

61780

Third Party Advisory

61816

Third Party Advisory

61855

Third Party Advisory

61857

Third Party Advisory

61873

Third Party Advisory

62228

Third Party Advisory

62312

Third Party Advisory

62343

Third Party Advisory

http://support.apple.com/kb/HT6495

Third Party Advisory

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

Third Party Advisory

20140926 GNU Bash Environmental Variable Command Injection Vulnerability

Third Party Advisory

DSA-3032

Third Party Advisory

VU#252743

Third Party Advisory, US Government Resource

MDVSA-2015:164

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory, VDB Entry

70103

Third Party Advisory, VDB Entry

USN-2362-1

Third Party Advisory

TA14-268A

Third Party Advisory, US Government Resource

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

Third Party Advisory

http://www.websense.com/support/article/kbarticle/Vulnerabilities-resolved-in-TRITON-APX-Version-8-0

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

https://access.redhat.com/articles/1200223

Third Party Advisory

https://access.redhat.com/node/1200223

Third Party Advisory

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

Issue Tracking, Patch, Third Party Advisory

https://help.ecostruxureit.com/display/public/UADCO8x/StruxureWare+Data+Center+Operation+Software+Vulnerability+Fixes

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

https://securityblog.redhat.com/2014/09/24/bash-specially-crafted-environment-variables-code-injection-attack/

Exploit, Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

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

Third Party Advisory

34879

Third Party Advisory, VDB Entry

37816

Third Party Advisory, VDB Entry

38849

Third Party Advisory, VDB Entry

39918

Exploit, Third Party Advisory, VDB Entry

40619

Third Party Advisory, VDB Entry

40938

Third Party Advisory, VDB Entry

42938

Third Party Advisory, VDB Entry

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

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.