What The Massive Shellshock Exploit Means For You

shellshock The Plain Mans 10 Point Guide to What The Massive Shellshock Exploit Means For You

The big tech news of the moment, and probably of the year or decade, is the revelation about a massive security hole in something called Bash, which is an arcane bit of geek code which is installed on many of the computers which power and host the Internet (and also Apple Mac computers). Here’s our plain man’s guide to what it means for you.

1. Over 51% of all web servers (i.e. websites) are running on the Linux operating system. Bash was historically a commonly used software component of Linux. Therefore the vulnerability instantly makes all these machines potentially susceptible to attack. That is a Very Big Deal. Because Apple Macs also use Linux as the basic system, this means Macs are also vulnerable. But see below.

2. The exploit only affects web servers directly, i.e. computers which are connected to the Internet, and operate webcode or websites. So your laptop computer will likely not be vulnerable unless you have some web server programs installed. In addition this web server code needs to include CGI and Bash for it to be exploitable. Very geek.

3. It is not clear how many web server computers are vulnerable, because it is not clear how much CGI and Bash is still being used. Most websites now use newer technologies, but there are still a not insignificant number of web computers using ‘back-end’ functions where Bash/CGI may be employed. However in general terms, Linux hardware like Android phones and home Internet routers should be safe, because they do not use those components.

shellshock3 The Plain Mans 10 Point Guide to What The Massive Shellshock Exploit Means For You

4. In order for the most serious part of the exploit to be run, the attacker needs to have access to the system in the first place (i.e. login, permissions etc), which immediately means the server then has much more of a security problem than just Shellshock. However, there is a form of attack where a remote attacker could add a nasty command to a web browser, which could suck private data from a web server like passwords, or other private information. This second form of attack is the one which worries security people the most.

5. Almost all of the major distributions of Linux have already had patches installed. Shellshock is therefore primarily of concern mainly for older, or small business computer installations, which may be running unpatched (i.e. unfixed) versions for a long period. Apple has yet to issue a patch for the problem. Similarly older or smaller web hosting services with sloppy security and upgrade procedures will be vulnerable.

6. How to test if your computer is vulnerable (warning – geek stuff): Run –

env x=’() { :;}; echo vulnerable’ bash -c “echo this is a test”

If your computer is OK, you will see :

bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x’
this is a test

If your computer is NOT OK, you will see:

env x=’() { :;}; echo vulnerable’ bash -c “echo this is a test”
this is a test

7. How to fix your computer if it is vulnerable (see above warning):
1) open a terminal
2) type “sudo yum -y update bash”
3) wait until it says it’s finished, then log out of your computer and log back in.

8. Just to repeat: Shellshock is not a problem in and of itself if your device is securely protected by having authentication on all open ports, and full blown security systems in place around the CGI/Bash implementation. So while there are 78 million web servers which may potentially be vulnerable right now, it will still require the other components of the attack to be in place. Even so, one estimate suggests that between 3000 and 3 million computers (!) POSSIBLY could be vulnerable.

9. Again, if you do not run a web connected computer with CGI and Bash components installed, you will not be vulnerable at all. Windows itself is not vulnerable, it is only Linux systems (and to a lesser degree ordinary consumer Apple Macs). Despite rumours, there are no reports as yet of small Linux hardware devices (e.g. GPS, phones, security etc) being vulnerable, because most of them do not use Bash.

shellshockscanner The Plain Mans 10 Point Guide to What The Massive Shellshock Exploit Means For You

10. You can use this Shellshock Scanner to test whether your website or webserver is vulnerable to the problem.

Note: You can read an excellent, more technical, summary of the bug here.



Credit:  Nigel

Remote exploit vulnerability in bash CVE-2014-6271


A remotely exploitable vulnerability has been discovered by Stephane Chazelas in bash on Linux and it is unpleasant. The vulnerability has the CVE identifier CVE-2014-6271 and has been given the name Shellshock by some. This affects Debian as well as other Linux distributions. You will need to patch ASAP.

Bash supports exporting shell variables as well as shell functions to other bash instances. This is accomplished through the process environment to a child process.

The major attack vectors that have been identified in this case are HTTP requests and CGI scripts.

From Akamai:

“Akamai has validated the existence of the vulnerability in bash, and confirmed its presence in bash for an extended period of time. We have also verified that this vulnerability is exposed in ssh—but only to authenticated sessions. Web applications like cgi-scripts may be vulnerable based on a number of factors; including calling other applications through a shell, or evaluating sections of code through a shell.”

There are several functional mitigations for this vulnerability: upgrading to a new version of bash, replacing bash with an alternate shell, limiting access to vulnerable services, or filtering inputs to vulnerable services. Akamai has created a WAF rule to filter this exploit; see “For Web Applications” below for details.
If you have a username in your authorization header this could also be an attack vector.

Another attack surface is OpenSSH through the use of AcceptEnv variables. As well through TERM and SSH_ORIGINAL_COMMAND. An environmental variable with an arbitrary name can carry a nefarious function which can enable network exploitation. This is fire bad.

The race is on. Will you be able to patch before Metasploit has a working exploit?

Tod Beardsley, engineering manager from Rapid7, had this to say,

“As you might have guessed, we’re busy at work putting together a Metasploit module that demonstrates the bash bug (CVE-2014-6271), as is the rest of the world of open source security contributors. I expect to see a first version today.

That said, it’s difficult to write one “bash bug” exploit — this is the sort of exploit that will be lurking around in all various and sundry sorts of software, both local and remote. It’s quite common for embedded devices with web-enabled front-ends to shuttle user input back and forth via bash shells, for example — routers, SCADA/ICS devices, medical equipment, and all sorts of webified gadgets are likely to be exposed.

The module we’re cooking up today will be as generic as we can make it, so people have a realistic chance of testing their devices. I expect that this will show up in more than one software package, though, so stay tuned.”

[UPDATE]: Received word from Tod at Rapid7 that the Metasploit module for the bash vulnerability was completed at 8:26 pm EDT.

Patch your systems now…GO!

Support Information:




Credit:  Dave Lewis

Protect Apache web-server from application DoS attacks (Ubuntu)

This tutorial assumes that you have a running Ubuntu Server, that networking has been set up, and that you have ssh access.

Apache2 is the default web-server used by many Linux installations. It is not the only one available, or the best for all circumstances, but it covers many usage scenarios. During the installation, you may be asked which web-server to reconfigure automatically. Answer ‘apache2’.

Install Apache2

Use the following command to install Apache2 and other libraries.

$ sudo apt-get -y install apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec php-pear php-auth php5-mcrypt mcrypt libapache2-mod-suphp libopenssl-ruby libapache2-mod-ruby

Update Timezone and Check Correct Time

To reduce confusion with shared or mirrored data, all servers ought to run as close to as in-sync as possible. Some cryptographic key management systems require accurate time. Lastly, for corporate servers, Sarbanes-Oxley and HIPAA Security Rules require accurate timestamping.

$ sudo apt-get -y install openntpd tzdata
$ sudo dpkg-reconfigure tzdata
$ sudo service openntpd restart

Disable AppArmor Conflicts

While AppArmor is a suite that does provide an additional layer of security, it is my opinion that custom profiles will need to be created for each system. That is something not covered in this tutorial. So for now, we are going to disable it to prevent conflicts with any default configurations.

$ sudo /etc/init.d/apparmor stop
$ sudo update-rc.d -f apparmor remove
$ sudo apt-get remove apparmor apparmor-utils

Note: disabling AppArmor is not recommended for a production web server. For those wanting to create a custom AppArmor profile, refer to the official documentation.

Stop DDoS Attacks

A DDoS attack is a distributed denial-of-service attack. An Apache module exists to stop such attacks.

$ sudo apt-get -y install libapache2-mod-evasive
$ sudo mkdir -p /var/log/apache2/evasive
$ sudo chown -R www-data:root /var/log/apache2/evasive

Append the following to the bottom of mod-evasive.load:

$ sudo nano /etc/apache2/mods-available/mod-evasive.load

DOSHashTableSize 2048
DOSPageCount 20            # maximum number of requests for the same page
DOSSiteCount 300           # total number of requests for any object by the same client IP on the same listener
DOSPageInterval 1.0        # interval for the page count threshold
DOSSiteInterval 1.0        # interval for the site count threshold
DOSBlockingPeriod 10.0     # time that a client IP will be blocked for
DOSLogDir “/var/log/apache2/evasive”
DOSEmailNotify admin@domain.com

Stop Slowloris Attacks

An Apache modules also exist for Slowloris attacks, though the module name depends on which version of Ubuntu that you are using. For Ubuntu 12.10 or later:

$ sudo apt-get -y install libapache2-mod-qos

Then check configuration in qos.conf:

$ sudo nano /etc/apache2/mods-available/qos.conf
## QoS Settings
<IfModule mod_qos.c>
    # handles connections from up to 100000 different IPs
    QS_ClientEntries 100000
    # will allow only 50 connections per IP
    QS_SrvMaxConnPerIP 50
    # maximum number of active TCP connections is limited to 256
    MaxClients              256 
    # disables keep-alive when 70% of the TCP connections are occupied:
    QS_SrvMaxConnClose      180
    # minimum request/response speed (deny slow clients blocking the server,     
    # ie. slowloris keeping connections open without requesting anything):
    QS_SrvMinDataRate       150 1200
    # and limit request header and body (carefull, that limits uploads and 
    # post requests too):
    # LimitRequestFields      30
    # QS_LimitRequestBody     102400

Note: If you are running a version of Ubuntu prior to 12.04, use the following instead.

$ sudo apt-get -y install libapache2-mod-antiloris

Check config in antiloris.conf.

$ sudo nano /etc/apache2/mods-available/antiloris.conf
<IfModule mod_antiloris.c>
	# Maximum simultaneous connections in READ state per IP address 
	IPReadLimit 5 

Stop DNS Injection Attacks

Spamhaus is a module that uses DNSBL in order to block spam relay via web forms, preventing URL injection, block http DDoS attacks from bots and generally protecting the server from known bad IP addresses.

$ sudo apt-get -y install libapache2-mod-spamhaus
$ sudo touch /etc/spamhaus.wl

Append the config to apache2.conf

$ sudo nano /etc/apache2/apache2.conf
<IfModule mod_spamhaus.c>
  MS_WhiteList /etc/spamhaus.wl 
  MS_CacheSize 256 

Restart Apache to load new modules.

$ sudo service apache2 restart

Now the webserver has been installed and is up and running. Point your web browser at your domain for a default message that confirms you are working. As a final check, run the following to see if your server has any error message. If there are errors, you will want to Google them and address them now.

$ sudo tail -200 /var/log/syslog


Installing BeEF on Ubuntu 12.10 LTS

BeEF - Browser Exploitation Frame

BeEF – The Browser Exploitation Framework Project is a penetration testing tool that focuses on the web browser.

Amid growing concerns about web-borne attacks against clients, including mobile clients, BeEF allows the professional penetration tester to assess the actual security posture of a target environment by using client-side attack vectors. Unlike other security frameworks, BeEF looks past the hardened network perimeter and client system, and examines exploitability within the context of the one open door: the web browser. BeEF will hook one or more web browsers and use them as beachheads for launching directed command modules and further attacks against the system from within the browser context.

Step 1 :

To download the latest version of BeEF to the current directory.

sudo -sH
cd /opt
apt-get install git
git clone git://github.com/beefproject/beef.git

Step 2 :

To install BeEF and her related packages.

cd beef

sudo apt-get install ruby1.9.1-dev libsqlite3-dev sqlite3 sqlite3-doc build-essential

sudo gem install bundler

sudo bundle install

Step 3 :

To run it.

sudo -sH
cd /opt/beef


Then point the Firefox to hxxp://[your IP address]:3000/ui/panel

Step 4 :

To update it.

sudo -sH
cd /opt/beef


Remarks :

If you also installed Metasploit, you can integrate Metasploit to BeEF to perform attacks, such as browsers autopwn.

Credit: Samiux