oss-sec mailing list archives

Re: CVE-2016-0634 -- bash prompt expanding $HOSTNAME


From: John Haxby <john.haxby () oracle com>
Date: Sun, 18 Sep 2016 20:06:57 +0100


On 16 Sep 2016, at 19:49, Chet Ramey <chet.ramey () case edu> wrote:

On 9/16/16 1:38 PM, Jan Schaumann wrote:
John Haxby <john.haxby () oracle com> wrote:

(I didn't get this message.)

Sorry about that, I thought I’d cc’d you with the right address.



A little while ago, one of our users discovered that by setting the
hostname to $(something unpleasant), bash would run "something
unpleasant" when it expanded \h in the prompt string.

This issue has been public since October, 2015 in Ubuntu's bug tracking
system.


Yes, the message was more to let people know that CVE-2016-0634  had been assigned for this issue.   Do you have a link 
to the Ubuntu issue and a different CVE number?


To clarify: this is only triggered if the hostname has been set, not the
$HOSTNAME variable, right?

Bash doesn't use $HOSTNAME; it sets it if it's not already set.  The
shell's idea of the current hostname is set using gethostname().  If
gethostname() fails, the hostname gets set to "??host??".  The \h
prompt expansion uses the shell's idea of the current hostname.

If your privileged application (either a user with privilege or a hostname-
setting agent) allows the hostname to be set to any arbitrary string of
characters, you're going to have problems regardless.


Yes, that’s correct.   A while ago there was a problem that dhcp would let a malicious dhcp server use a hostname of 
the attackers choosing.   That was bad not least because would expand whatever was given.   The linux sethostname(2) 
system call doesn’t make any restrictions on what you can use for a system call so any agent (not just that old dhcp 
version) that sets the hostname could potentially trigger this.   The bar is obviously set quite high for this: you 
need to find an agent that you can persuade to set the hostname for you — any agent that just blindly sets the hostname 
to $(do something bad) is broken, but bash shouldn’t make the situation worse by giving you complete control over the 
machine.


Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
               ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet () case edu    http://cnswww.cns.cwru.edu/~chet/


Current thread: