oss-sec mailing list archives

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


From: Chet Ramey <chet.ramey () case edu>
Date: Fri, 16 Sep 2016 14:49:11 -0400

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

(I didn't get this message.)

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.


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.

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: