Remote code execution through bash CVE-2014-6271

A new vulnerability has been discovered in bash, related to how environment variables are processed. You can read more on redhat security blog. This vulnerability can be used to execute remote code, even via ssh, if the remote shell is bash.

In ssh, you can use the ForceCommand in sshd_config, or the “command’ option in .ssh/authorized_keys. This option ‘Specifies that the command is executed whenever this key is used for authentication. The command supplied by the user (if any) is ignored.’ (man sshd).
So you can use it for example to auto launch a backup script when the user connect, and nothing more.

For example in test/.ssh/authorized_keys,

command="/usr/local/bin/" ssh-rsa [...thepublickey...]

Now, a “ssh” will automatically launch this script, and that’s all.

With CVE-2014-6271, the flaw is triggered when extra code is added to the end of these function definitions (inside the environment variable).

$ ssh '() { ignored; }; /bin/date'
Wed Sep 24 18:32:41 CEST 2014

So, instead of execute your backup script, your custom command is launched !
From there; everything is possible…
So especially update your bash package if you have this kind of configuration !

Note: of course, in this case, the remote attacker need a valid account on the machine. But if you use command/ForceCommand to provide git-shell access for example, this can be a real problem !

Sources :