Original issue date: October 8, 1996<BR>
Last revised: September 24, 1997<BR>
Updated copyright statement

<P>A complete revision history is at the end of this file.

The original technical content for this advisory
was published by the IBM-ERS response team and
is used here with their permission.

<P>This advisory describes two problems with the GNU Project's Bourne Again
SHell (bash): one in yy_string_get() and one in yy_readline_get().

<P>The vulnerability in yy_string_get() allows the character with value 255
decimal to be used as a command separator. When used in environments where
users provide strings to be used as commands or arguments to commands, bash
can be tricked into executing arbitrary commands.

<P>When the advisory was first published, was not clear whether the problem with
yy_readline_get() resulted in an exploitable vulnerability. As of November
1996, it appears that the problem is not exploitable in yy_readline_get.

<P>The problems affect bash versions 1.14.6 and earlier.

<P>The CERT/CC team recommends that you upgrade to bash 1.14.7 as soon as
possible, as discussed in Section III.A below. Section III.B contains a
patch for 1.14.7, which we recommend using to address the yy_readline_get()
problem.

<P>We will update this advisory as we receive additional information.
Please check advisory files regularly for updates that relate to your site.

<H2>I. Description</H2>


<H3>A. Introduction</H3>


The GNU Project's Bourne Again SHell (bash) is a drop-in replacement
for the UNIX Bourne shell (/bin/sh). It offers the same syntax as the
standard shell, and it also includes additional functionality such as
job control, command line editing, and history.

<P>Although bash can be compiled and installed on almost any UNIX
platform, its most prevalent use is on &quot;free&quot; versions of UNIX such as
Linux, where it has been installed as &quot;/bin/sh&quot; (the default shell for
most uses).

<P>The bash source code is freely available from many sites on the
Internet.

<H3>B. Vulnerability Details</H3>

<H4>1. Vulnerability in yy_string_get()</H4>


There is a variable declaration error in the &quot;yy_string_get()&quot;
function in the &quot;parse.y&quot; module of the &quot;bash&quot; source code. This
function is responsible for parsing the user-provided command line
into separate tokens (commands, special characters, arguments, etc.).
The error involves the variable &quot;string&quot;, which has been declared to
be of type &quot;char *&quot;.

<P>The &quot;string&quot; variable is used to traverse the character string
containing the command line to be parsed. As characters are
retrieved from this pointer, they are stored in a variable of type
&quot;int&quot;. On systems/compilers where the &quot;char&quot; type defaults to
&quot;signed char&quot; this value will be sign-extended when it is assigned
to the  &quot;int&quot; variable. For character code 255 decimal (-1 in two's
complement form), this sign extension results in the value (-1)
being assigned to the integer.

<P>However, (-1) is used in other parts of the parser to indicate the
end of a command. Thus, the character code 255 decimal (377 octal)
will serve as an unintended command separator for commands given to
bash via the &quot;-c&quot; option. For example,
<PRE>
         bash -c 'ls\377who'
</PRE>
(where &quot;\377&quot; represents the single character with value 255 decimal)
will execute two commands, &quot;ls&quot; and &quot;who&quot;.

<P>Note about yy_readline_get()<BR>
A similar problem exists with the &quot;yy_readline_get()&quot; function, which
is also in the file &quot;parse.y&quot; and which is used to read commands in
interactive shells (ones that print a prompt and read from the
keyboard, a shell script, or a pipe).

<P>However, it appears that this problem does not produce an exploitable
vulnerability.

<H2>II. Impact</H2>

This unexpected command separator can be dangerous, especially on systems
such as Linux where bash has been installed as &quot;/bin/sh,&quot; when a program
executes a command with a string provided by a user as an argument using
the &quot;system()&quot; or &quot;popen()&quot; functions (or by calling &quot;/bin/sh -c string&quot;
directly).

<P>This is especially true for the CGI programming interface in World Wide
Web servers, many of which do not strip out characters with value 255
decimal. If a user sending data to the server can specify the character
code 255 in a string that is passed to a shell, and that shell is bash,
the user can execute any arbitrary command with the user-id and
permissions of the user running the server (frequently &quot;root&quot;).

<P>The bash built-in commands &quot;eval,&quot; &quot;source,&quot; and &quot;fc&quot; are also
potentially vulnerable to this problem.

<H2>III. Solution</H2>


Install the most current version of bash. On 27 August 1996, Version
1.14.7 of bash was released;  It is available from

<P>
<A HREF=ftp://slc2.ins.cwru.edu/pub/dist/bash-1.14.7.tar.gz>ftp://slc2.ins.cwru.edu/pub/dist/bash-1.14.7.tar.gz</A>

<P>This version addresses the vulnerability in yy_string_get.

<P>When this advisory was first released, we included a patch for
yy_readline_get. It now appears that the patch is unnecessary as the
problem is not exploitable in yy_readline_get. Upgrading to the current
version of bash is sufficient.
<HR>
<H1>Appendix A</H1>

The following is vendor-supplied information.<BR>
For the most up-to-date information, contact your vendor.

<H3>IBM Corporation</H3>

AIX does not ship with the bash shell.

<P>IBM and AIX are registered trademarks of International<BR>
Business Machines Corporation.



<H3>Silicon Graphics, Inc.</H3>

SGI has distributed bash (version 1.14.6) as part of the Freeware 1.0
CDROM.  This collection of software has been compiled for IRIX as a
service to our customers, but is furnished without formal SGI support.

<P>The problem identified by IBM in bash is present in the version of bash
on the Freeware 1.0 CDROM.  This CDROM included both the source code
for bash an compiled versions of it.

<P>SGI urges customers to recompile bash after making the changes in
parse.y suggested by IBM.

<P>As a service similar to that of the original Freeware 1.0 CDROM, SGI
intends to make available a compiled version of bash and its source in
the near future.  This action does not necessarily imply a commitment to any
future support actions for the programs found on the Freeware 1.0
CDROM.
<H3>Linux</H3>

Patches for the following Linux versions are available.

<P>SuSE 4.2

<P>
<A HREF=ftp://ftp.suse.de/suse_update/suse42/a1/bash.tgz>ftp://ftp.suse.de/suse_update/suse42/a1/bash.tgz</A>

<P>Red Hat 3.0.3

<P>
<A HREF=ftp://ftp.redhat.com/pub/redhat/updates/3.0.3/{architecture}/bash-1.14.6.8.{architecture}.rpm>ftp://ftp.redhat.com/pub/redhat/updates/3.0.3/{architecture}/bash-1.14.6.8.{architecture}.rpm</A>

<P>Yggdrasil

<P>Patched bash source and binary tar files are now  FTPable from
<BR>
<A HREF=ftp://ftp.yggdrasil.com/pub/support/fall95>ftp://ftp.yggdrasil.com/pub/support/fall95</A>


WGS Linux Pro

<P>
<A HREF=ftp://ftp.wgs.com/pub/linux/redhat/updates/3.0.3/i386/bash-1.14.6-8.i386.rpm>ftp://ftp.wgs.com/pub/linux/redhat/updates/3.0.3/i386/bash-1.14.6-8.i386.rpm</A>

<P>Caldera

<P> Have built the new bash-1.14.7 code from prep.ai.mit.edu
-/pub/gnu. Tested only insofar as to ascertain that the security bug
is fixed.  Binary and source RPMs live in ftp -

<P>
<A HREF=ftp://ftp.caldera.com/pub/cnd-1.0/updates/bash-1.14.7-1.i386.rpm>ftp://ftp.caldera.com/pub/cnd-1.0/updates/bash-1.14.7-1.i386.rpm</A>

<P>
<A HREF=ftp://ftp.caldera.com/pub/cnd-1.0/updates/bash-1.14.7-1.src.rpm>ftp://ftp.caldera.com/pub/cnd-1.0/updates/bash-1.14.7-1.src.rpm</A>

<P>
<HR>

<P>The CERT Coordination Center thanks IBM-ERS for permission to reproduce the
technical content in their IBM Emergency Response Service Security
Vulnerability Alerts ERS-SVA-E01-1006:004.1 and ERS-SVA-E01-1006:004.2.
These alerts are copyrighted 1996 International Business Machines Corporation.

<P><HR>

<!--#include virtual="/include/footer_nocopyright.html" -->
<P>Copyright 1996 Carnegie Mellon University.</P>

<HR>

Revision History
<PRE>
Sep. 24, 1997  Updated copyright statement
Nov. 13, 1996  Noted that yy_readline_get does not require the patch included
               in the original advisory. Removed the patch from Sec. III.
Oct. 14, 1996  Added Appendix A - vendor information.
</PRE>