|
| 1 | +CVE-2014-6271 |
| 2 | +=== |
| 3 | + |
| 4 | +[1. Overview](#overview) |
| 5 | +[2. HTTP Header](#httpheader) |
| 6 | + |
| 7 | +<a name="overview"></a> |
| 8 | +##1. Overview |
| 9 | +=== |
| 10 | + |
| 11 | +**CVE-2014-6271** is a real nasty one; this vulnerability is in one of those pervasive pieces of software that comes with nearly every unixy type device- the [bash](http://tiswww.case.edu/php/chet/bash/bashtop.html), the Bourne-Again SHell. Let's test to see if your servers|workstations|internet-of-things is vulnerable: |
| 12 | + |
| 13 | +Open a shell and paste: |
| 14 | +``` |
| 15 | +env x='() { :;}; echo vulnerable' bash -c 'echo hello' |
| 16 | +``` |
| 17 | + |
| 18 | +If you are not vulnerable, then the following will be shown: |
| 19 | +``` |
| 20 | +bash: warning: x: ignoring function definition attempt |
| 21 | +bash: error importing function definition for `x' |
| 22 | +hello |
| 23 | +``` |
| 24 | +If you are vulnerable, then you will see: |
| 25 | +``` |
| 26 | +vulnerable |
| 27 | +hello |
| 28 | +``` |
| 29 | + |
| 30 | +If you are vulnerable you should update your device immediately. I have a feeling that this is the kind of exploit that is going to start cropping up in a large variety of cases. I'll try to keep this updated to detect the various methods as the situation evolves. |
| 31 | + |
| 32 | +<a name="httpheader"></a> |
| 33 | +##2. HTTP Header Attack |
| 34 | +=== |
| 35 | + |
| 36 | + |
| 37 | +First POC is out- attempting to attack bash based cgi scripts; [internet wide scans](http://blog.erratasec.com/2014/09/bash-shellshock-scan-of-internet.html) have been kicked off and I expect to see this genuinely weaponized before the evening is out. |
| 38 | + |
| 39 | +A vulnerable piece of code will look something like this: |
| 40 | + |
| 41 | +``` |
| 42 | +#!/bin/bash |
| 43 | +
|
| 44 | +echo Content-type: text/html |
| 45 | +echo "" |
| 46 | +
|
| 47 | +/bin/cat << EOM |
| 48 | +<HTML> |
| 49 | +<HEAD><TITLE>File Output: /home/user1/public_html/text-file.txt </TITLE> |
| 50 | +</HEAD> |
| 51 | +<BODY bgcolor="#cccccc" text="#000000"> |
| 52 | +<P> |
| 53 | +<SMALL> |
| 54 | +<PRE> |
| 55 | +EOM |
| 56 | +
|
| 57 | +/bin/env |
| 58 | +
|
| 59 | +CAT << EOM |
| 60 | +</PRE> |
| 61 | +</SMALL> |
| 62 | +<P> |
| 63 | +</BODY> |
| 64 | +</HTML> |
| 65 | +EOM |
| 66 | +``` |
| 67 | +[[source](http://www.yolinux.com/TUTORIALS/LinuxTutorialCgiShellScript.html) |
| 68 | + |
| 69 | +This piece of code will output something like this: |
| 70 | +``` |
| 71 | +<HTML> |
| 72 | +<HEAD><TITLE>File Output: /home/user1/public_html/text-file.txt </TITLE> |
| 73 | +</HEAD> |
| 74 | +<BODY bgcolor="#cccccc" text="#000000"> |
| 75 | +<P> |
| 76 | +<SMALL> |
| 77 | +<PRE> |
| 78 | +SERVER_SIGNATURE= |
| 79 | +Apache/2.0.40 Server at localhost Port 80 |
| 80 | +
|
| 81 | +
|
| 82 | +UNIQUE_ID=DErk6n8AAAEAAAblFQEAAAAD |
| 83 | +HTTP_USER_AGENT=Mozilla/4.8 [en] (X11; U; Linux 2.4.18-27.8.0 i586) |
| 84 | +SERVER_PORT=80 |
| 85 | +HTTP_HOST=localhost |
| 86 | +DOCUMENT_ROOT=/var/www/html |
| 87 | +HTTP_ACCEPT_CHARSET=iso-8859-1,*,utf-8 |
| 88 | +SCRIPT_FILENAME=/var/www/cgi-bin/env.sh |
| 89 | +REQUEST_URI=/cgi-bin/env.sh |
| 90 | +SCRIPT_NAME=/cgi-bin/env.sh |
| 91 | +HTTP_CONNECTION=Keep-Alive |
| 92 | +REMOTE_PORT=32984 |
| 93 | +PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin |
| 94 | +PWD=/var/www/cgi-bin |
| 95 | +SERVER_ADMIN=root@localhost |
| 96 | +HTTP_ACCEPT_LANGUAGE=en |
| 97 | +HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */* |
| 98 | +REMOTE_ADDR=127.0.0.1 |
| 99 | +SHLVL=1 |
| 100 | +SERVER_NAME=localhost |
| 101 | +SERVER_SOFTWARE=Apache/2.0.40 (Red Hat Linux) |
| 102 | +QUERY_STRING= |
| 103 | +SERVER_ADDR=127.0.0.1 |
| 104 | +GATEWAY_INTERFACE=CGI/1.1 |
| 105 | +SERVER_PROTOCOL=HTTP/1.0 |
| 106 | +HTTP_ACCEPT_ENCODING=gzip |
| 107 | +REQUEST_METHOD=GET |
| 108 | +_=/bin/env |
| 109 | +</PRE> |
| 110 | +</SMALL> |
| 111 | +<P> |
| 112 | +</BODY> |
| 113 | +</HTML> |
| 114 | +``` |
0 commit comments