Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!

TUCoPS :: Unix :: General :: ciacg041.txt

Bash Vulnerability


                       The U.S. Department of Energy
                    Computer Incident Advisory Capability
                           ___  __ __    _     ___
                          /       |     /_\   /
                          \___  __|__  /   \  \___

                             INFORMATION BULLETIN

                         Vulnerability in BASH Program

August 29, 1996 15:00 GMT                                          Number G-41
PROBLEM:       A variable declaration error in the GNU Project's BASH (Bourne 
               Again SHell) program allows the character with value 255 
               decimal to be used as a command separator. 
PLATFORM:      BASH 1.14.6 and any earlier versions. 
DAMAGE:        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. 
SOLUTION:      Apply the patches listed in the vendor bulletin below. 
VULNERABILITY  This vulnerability is becoming widely known. 

This is a combination of two bulletins sent out by IBM on the BASH 


                  =======  ============    ======       ======
                  =======  ==============  =======     =======
                    ===      ===     ====    ======   ======
                    ===      ===========     ======= =======
                    ===      ===========     === ======= ===
                    ===      ===     ====    ===  =====  ===
                  =======  ==============  =====   ===   =====
                  =======  ============    =====    =    =====

                           EMERGENCY RESPONSE SERVICE

21 August 1996 13:00 GMT                       Number: ERS-SVA-E01-1996:004.1
28 August 1996 18:00 GMT                       Number: ERS-SVA-E01-1996:004.2
                             VULNERABILITY  SUMMARY

VULNERABILITY:  A variable declaration error in "bash" allows the character
		with value 255 decimal to be used as a command separator.

PLATFORMS:	Bash 1.14.6 and earlier versions.

SOLUTION:	Apply the patch provided below.

THREAT:		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.

                              DETAILED INFORMATION

I. Description

   A. Introduction

      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, but also includes additional functionality such as job
      control, command line editing, and history.

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

      The "bash" source code is freely available from many sites on the

   B. Vulnerability Details

      There is a variable declaration error in the "yy_string_get()" function
      in the "parser.y" module of the "bash" 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 "string," which has been declared to be of type
      "char *."

      The "string" 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 "int."  On
      systems/compilers where the "char" type defaults to "signed char", this
      vaule will be sign-extended when it is assigned to the "int" 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.

      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 "-c" option.  For example,

	bash -c 'ls\377who'

      (where "\377" represents the single character with value 255 decimal)
      will execute two commands, "ls" and "who."

II. Impact

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

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 "root").

The "bash" built-in commands "eval," "source," and "fc" are also potentially
vulnerable to this problem.

III. Solutions

How to alleviate the problem

   This problem can be alleviated by changing the declaration of the
   "string" variable in the "yy_string_get()" function from "char *" to
   "unsigned char *."

I. New version of "bash" released

   On 27 August 1996, Version 1.14.7 of "bash" was released.  You can obtain
   this new version from:

   (It will also be available from the usual GNU archives in a few days.)

II. Updated patch for second potential problem

   IBM-ERS has now received information that a similar problem exists with 
   the "yy_readline_get()" function, also in the file "parse.y," 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).

   It is not clear that this problem produces any exploitable vulnerabilities
   in the "bash" program, however, you may wish to address the problem for
   completeness' sake.

   This problem can be alleviated by applying the patch below to the "bash"
   source code, then recompiling the program, and installing the new version.

   The patch below is for Version 1.14.7 of "bash."  Source code for this
   version can be obtained from the site listed above, as well as many other
   sites around the Internet.

- ---------------------------------- cut here --------------------------------
*** parse.y.old	Mon Aug 26 11:15:55 1996
- --- parse.y	Wed Aug 28 08:49:15 1996
*** 801,807 ****
  #if defined (READLINE)
  char *current_readline_prompt = (char *)NULL;
! char *current_readline_line = (char *)NULL;
  int current_readline_line_index = 0;
  static int
- --- 801,807 ----
  #if defined (READLINE)
  char *current_readline_prompt = (char *)NULL;
! unsigned char *current_readline_line = (unsigned char *)NULL;
  int current_readline_line_index = 0;
  static int
- ---------------------------------- cut here --------------------------------

   To apply this patch, save the text between the two "--- cut here ---" lines
   to a file, change directories to the "bash" source directory, and issue the

	patch < filename

   If you do not have the "patch" program, you can obtain it from

   or you can apply the patch by hand.

   After applying the patch, recompile and reinstall the "bash" program by
   following the directions in the "INSTALL" file, included as part of the
   "bash" distribution.


IV. Acknowledgements

IBM-ERS would like to thank the IBM Global Security Analysis Laboratory at the
IBM T. J. Watson Research Center and Jens Schweikhardt of the DFN Network 
Operations Center for their discovery of this vulnerability, bringing it to 
our attention, providing the patch to fix it, and assistance in developing 
this alert.  IBM-ERS would like to thank DFN-CERT for relaying the information
to us.

UNIX is a technology trademark of X/Open Company, Ltd.



CIAC wishes to acknowledge the contributions of IBM for the 
information contained in this bulletin.

CIAC, the Computer Incident Advisory Capability, is the computer
security incident response team for the U.S. Department of Energy
(DOE) and the emergency backup response team for the National
Institutes of Health (NIH). CIAC is located at the Lawrence Livermore
National Laboratory in Livermore, California. CIAC is also a founding
member of FIRST, the Forum of Incident Response and Security Teams, a
global organization established to foster cooperation and coordination
among computer security teams worldwide.

CIAC services are available to DOE, DOE contractors, and the NIH. CIAC
can be contacted at:
    Voice:    +1 510-422-8193
    FAX:      +1 510-423-8002
    STU-III:  +1 510-423-2604

For emergencies and off-hour assistance, DOE, DOE contractor sites,
and the NIH may contact CIAC 24-hours a day. During off hours (5PM -
8AM PST), call the CIAC voice number 510-422-8193 and leave a message,
or call 800-759-7243 (800-SKY-PAGE) to send a Sky Page. CIAC has two
Sky Page PIN numbers, the primary PIN number, 8550070, is for the CIAC
duty person, and the secondary PIN number, 8550074 is for the CIAC
Project Leader.

Previous CIAC notices, anti-virus software, and other information are
available from the CIAC Computer Security Archive.

   World Wide Web:
   Anonymous FTP: (
   Modem access:        +1 (510) 423-4753 (28.8K baud)
                        +1 (510) 423-3331 (28.8K baud)

CIAC has several self-subscribing mailing lists for electronic
1. CIAC-BULLETIN for Advisories, highest priority - time critical
   information and Bulletins, important computer security information;
2. CIAC-NOTES for Notes, a collection of computer security articles;
3. SPI-ANNOUNCE for official news about Security Profile Inspector
   (SPI) software updates, new features, distribution and
4. SPI-NOTES, for discussion of problems and solutions regarding the
   use of SPI products.

Our mailing lists are managed by a public domain software package
called ListProcessor, which ignores E-mail header subject lines. To
subscribe (add yourself) to one of our mailing lists, send the
following request as the E-mail message body, substituting
valid information for LastName FirstName and PhoneNumber when sending

E-mail to
        subscribe list-name LastName, FirstName PhoneNumber
  e.g., subscribe ciac-notes OHara, Scarlett W. 404-555-1212 x36

You will receive an acknowledgment containing address, initial PIN,
and information on how to change either of them, cancel your
subscription, or get help.

PLEASE NOTE: Many users outside of the DOE, ESnet, and NIH computing
communities receive CIAC bulletins.  If you are not part of these
communities, please contact your agency's response team to report
incidents. Your agency's team will coordinate with CIAC. The Forum of
Incident Response and Security Teams (FIRST) is a world-wide
organization. A list of FIRST member organizations and their
constituencies can be obtained by sending email to with an empty subject line and a message body
containing the line: send first-contacts.

This document was prepared as an account of work sponsored by an
agency of the United States Government. Neither the United States
Government nor the University of California nor any of their
employees, makes any warranty, express or implied, or assumes any
legal liability or responsibility for the accuracy, completeness, or
usefulness of any information, apparatus, product, or process
disclosed, or represents that its use would not infringe privately
owned rights. Reference herein to any specific commercial products,
process, or service by trade name, trademark, manufacturer, or
otherwise, does not necessarily constitute or imply its endorsement,
recommendation or favoring by the United States Government or the
University of California. The views and opinions of authors expressed
herein do not necessarily state or reflect those of the United States
Government or the University of California, and shall not be used for
advertising or product endorsement purposes.

LAST 10 CIAC BULLETINS ISSUED (Previous bulletins available from CIAC)

G-31: FreeBSD Security Vulnerabilities (ppp, rdist, and rz)
G-32: HP-UX Vulnerabilities in expreserve, rpc.pcnfsd, rpc.statd
G-33: rdist vulnerability
G-34: HP-UX Vulnerabilities (netttune, SAM remote admin)
G-35: SUN Microsystems Solaris vold Vulnerability
G-36: HP-UX Vulnerabilities in elm and rdist Programs
G-37: Vulnerability in Adobe FrameMaker (fm_fls)
G-38: Linux Vulnerabilities in mount and umount Programs 
G-39: Vulnerability in expreserve
G-40: SGI admin and user Program Vulnerabilities

RECENT CIAC NOTES ISSUED (Previous Notes available from CIAC)

Notes 07 - 3/29/95     A comprehensive review of SATAN

Notes 08 - 4/4/95      A Courtney update

Notes 09 - 4/24/95     More on the "Good Times" virus urban legend

Notes 10 - 6/16/95     PKZ300B Trojan, Logdaemon/FreeBSD, vulnerability
                       in S/Key, EBOLA Virus Hoax, and Caibua Virus

Notes 11 - 7/31/95     Virus Update, Hats Off to Administrators,
                       America On-Line Virus Scare, SPI 3.2.2 Released, 
                       The Die_Hard Virus

Notes 12 - 9/12/95     Securely configuring Public Telnet Services, X
                       Windows, beta release of Merlin, Microsoft Word
                       Macro Viruses, Allegations of Inappropriate Data
                       Collection in Win95

Notes 96-01 - 3/18/96  Java and JavaScript Vulnerabilities, FIRST
                       Conference Announcement, Security and Web Search
                       Engines, Microsoft Word Macro Virus Update

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2015 AOH