home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / bashhole.txt / text0001.txt < prev   
Encoding:
Text File  |  2003-06-11  |  12.6 KB  |  303 lines

  1. Whilst I know you might not care for security problems on meditation,
  2. I just wanted to splode over the description of *why* this problem exists.
  3.  
  4. (If you read section B, it's very mycroftish.)
  5.  
  6.  
  7. ------------------------------------------------------------------------------
  8. register char *string;         vs.      register unsigned char *string;
  9. ------------------------------------------------------------------------------
  10.  
  11. Matt
  12. -----BEGIN PGP SIGNED MESSAGE-----
  13.  
  14.  
  15. AUSCERT has received the following Alert from the IBM ERS team concerning a
  16. vulnerability in the GNU "bash" shell.  It is passed on for your information.
  17.  
  18. If you believe that your system has been compromised, contact AUSCERT or your
  19. representative in FIRST (Forum of Incident Response and Security Teams).
  20.  
  21. AUSCERT maintains an anonymous FTP service which is found on:
  22. ftp://ftp.auscert.org.au/pub/.  This archive contains past SERT and AUSCERT
  23. Advisories, and other computer security information.
  24.  
  25. AUSCERT also maintains a World Wide Web service which is found on:
  26. http://www.auscert.org.au/.
  27.  
  28. Internet Email: auscert@auscert.org.au
  29. Facsimile:    (07) 3365 4477
  30. Telephone:    (07) 3365 4417 (International: +61 7 3365 4417)
  31.         AUSCERT personnel answer during Queensland business hours
  32.         which are GMT+10:00 (AEST).
  33.         On call after hours for emergencies.
  34.  
  35. - -- Begin Included Advisory --
  36.  
  37. - --ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--
  38. - ---EXTERNAL RELEASE---EXTERNAL RELEASE---EXTERNAL RELEASE---EXTERNAL
  39. RELEASE---
  40.  
  41.                   =======  ============    ======       ======
  42.                   =======  ==============  =======     =======
  43.                     ===      ===     ====    ======   ======
  44.                     ===      ===========     ======= =======
  45.                     ===      ===========     === ======= ===
  46.                     ===      ===     ====    ===  =====  ===
  47.                   =======  ==============  =====   ===   =====
  48.                   =======  ============    =====    =    =====
  49.  
  50.                            EMERGENCY RESPONSE SERVICE
  51.               SECURITY VULNERABILITY ALERT
  52.  
  53. 21 August 1996 13:00 GMT                         Number: ERS-SVA-E01-1996:004.1
  54. ===============================================================================
  55.                              VULNERABILITY  SUMMARY
  56.  
  57. VULNERABILITY:  A variable declaration error in "bash" allows the character
  58.         with value 255 decimal to be used as a command separator.
  59.  
  60. PLATFORMS:    Bash 1.14.6 and earlier versions.
  61.  
  62. SOLUTION:    Apply the patch provided below.
  63.  
  64. THREAT:        When used in environments where users provide strings to be
  65.         used as commands or arguments to commands, "bash" can be
  66.         tricked into executing arbitrary commands.
  67.  
  68. ===============================================================================
  69.                               DETAILED INFORMATION
  70.  
  71. I. Description
  72.  
  73.    A. Introduction
  74.  
  75.       The GNU Project's Bourne Again SHell ("bash") is a drop-in replacement
  76.       for the UNIX Bourne shell (/bin/sh).  It offers the same syntax as the
  77.       standard shell, but also includes additional functionality such as job
  78.       control, command line editing, and history.
  79.  
  80.       Although "bash" can be compiled and installed on almost any UNIX
  81.       platform, its most prevalent use is on "free" versions of UNIX such as
  82.       Linux, where it has been installed as "/bin/sh" (the default shell for
  83.       most uses).
  84.  
  85.       The "bash" source code is freely available from many sites on the
  86.       Internet.
  87.  
  88.    B. Vulnerability Details
  89.  
  90.       There is a variable declaration error in the "yy_string_get()" function
  91.       in the "parser.y" module of the "bash" source code.  This function is
  92.       responsible for parsing the user-provided command line into separate
  93.       tokens (commands, special characters, arguments, etc.).  The error
  94.       involves the variable "string," which has been declared to be of type
  95.       "char *."
  96.  
  97.       The "string" variable is used to traverse the character string
  98.       containing the command line to be parsed.  As characters are retrieved
  99.       from this pointer, they are stored in a variable of type "int."  On
  100.       systems/compilers where the "char" type defaults to "signed char", this
  101.       vaule will be sign-extended when it is assigned to the "int" variable.
  102.       For character code 255 decimal (-1 in two's complement form), this sign
  103.       extension results in the value (-1) being assigned to the integer.
  104.  
  105.       However, (-1) is used in other parts of the parser to indicate the end
  106.       of a command.  Thus, the character code 255 decimal (377 octal) will
  107.       serve as an unintended command separator for commands given to "bash"
  108.       via the "-c" option.  For example,
  109.  
  110.     bash -c 'ls\377who'
  111.  
  112.       (where "\377" represents the single character with value 255 decimal)
  113.       will execute two commands, "ls" and "who."
  114.  
  115. II. Impact
  116.  
  117. This unexpected command separator can be dangerous, especially on systems such
  118. as Linux where "bash" has been installed as "/bin/sh," when a program executes
  119. a command with a string provided by a user as an argument using the "system()"
  120. or "popen()" functions (or by calling "/bin/sh -c string" directly).
  121.  
  122. This is especially true for the CGI programming interface in World Wide Web
  123. servers, many of which do not strip out characters with value 255 decimal.  If
  124. a user sending data to the server can specify the character code 255 in a
  125. string that is passed to a shell, and that shell is "bash," the user can
  126. execute any arbitrary command with the user-id and permissions of the user
  127. running the server (frequently "root").
  128.  
  129. The "bash" built-in commands "eval," "source," and "fc" are also potentially
  130. vulnerable to this problem.
  131.  
  132. III. Solutions
  133.  
  134.    A. How to alleviate the problem
  135.  
  136.       This problem can be alleviated by changing the declaration of the
  137.       "string" variable in the "yy_string_get()" function from "char *" to
  138.       "unsigned char *."
  139.  
  140.    B. Official fix from the "bash" maintainers
  141.  
  142.       The "bash" maintainers have told us they plan to fix this problem in
  143.       Version 2.0 of "bash," but this will not be released for at least a few
  144.       more months.
  145.  
  146.    C. Unofficial fix until the official version is released
  147.  
  148.       Until the "bash" maintainers release Version 2.0, this problem can be
  149.       fixed by applying the patch below to the "bash" source code, recompiling
  150.       the program, and installing the new version.
  151.  
  152.       The patch below is for Version 1.14.6 of "bash."  Source code for this
  153.       version can be obtained from
  154.  
  155.      ftp://prep.ai.mit.edu/pub/gnu/bash-1.14.6.tar.gz
  156.  
  157.       as well as many other sites around the Internet.
  158.  
  159. - ---------------------------------- cut here
  160. ----------------------------------
  161. *** parse.y.old Thu Nov  2 15:00:51 1995
  162. - --- parse.y     Tue Aug 20 09:16:48 1996
  163. ***************
  164. *** 904,910 ****
  165.   static int
  166.   yy_string_get ()
  167.   {
  168. !   register char *string;
  169.     register int c;
  170.  
  171.     string = bash_input.location.string;
  172. - --- 904,910 ----
  173.   static int
  174.   yy_string_get ()
  175.   {
  176. !   register unsigned char *string;
  177.     register int c;
  178.  
  179.     string = bash_input.location.string;
  180. - ---------------------------------- cut here
  181. ----------------------------------
  182.  
  183.       To apply this patch, save the text between the two "--- cut here ---"
  184.       lines to a file, change directories to the "bash" source directory, and
  185.       issue the command
  186.  
  187.     patch < filename
  188.  
  189.       If you do not have the "patch" program, you can obtain it from
  190.  
  191.     ftp://prep.ai.mit.edu/pub/gnu/patch-2.1.tar.gz
  192.  
  193.       or you can apply the patch by hand.
  194.  
  195.       After applying the patch, recompile and reinstall the "bash" program by
  196.       following the directions in the "INSTALL" file, included as part of the
  197.       "bash" distribution.
  198.  
  199.       This patch is provided "AS IS" without warranty of any kind, including,
  200.       without limitation, any implied warranties of merchantibility or fitness
  201.       for a particular purpose.  This advisory does not create or imply any
  202.       support obligations or any other liability on the part of IBM or its
  203.       subsidiaries.
  204.  
  205. IV. Acknowledgements
  206.  
  207. IBM-ERS would like to thank the IBM Global Security Analysis Laboratory at the
  208. IBM T. J. Watson Research Center for their discovery of this vulnerability,
  209. bringing it to our attention, providing the patch to fix it, and assistance in
  210. developing this alert.
  211.  
  212. UNIX is a technology trademark of X/Open Company, Ltd.
  213.  
  214. ===============================================================================
  215.  
  216. IBM's Internet Emergency Response Service (IBM-ERS) is a subscription-based
  217. Internet security response service that includes computer security incident
  218. response and management, regular electronic verification of your Internet
  219. gateway(s), and security vulnerability alerts similar to this one that are
  220. tailored to your specific computing environment.  By acting as an extension
  221. of your own internal security staff, IBM-ERS's team of Internet security
  222. experts helps you quickly detect and respond to attacks and exposures across
  223. your Internet connection(s).
  224.  
  225. As a part of IBM's Business Recovery Services organization, the IBM Internet
  226. Emergency Response Service is a component of IBM's SecureWay(tm) line of
  227. security products and services.  From hardware to software to consulting,
  228. SecureWay solutions can give you the assurance and expertise you need to
  229. protect your valuable business resources.  To find out more about the IBM
  230. Internet Emergency Response Service, send an electronic mail message to
  231. ers-sales@vnet.ibm.com, or call 1-800-742-2493 (Prompt 4).
  232.  
  233. IBM-ERS maintains a site on the World Wide Web at http://www.ers.ibm.com/.
  234. Visit the site for information about the service, copies of security alerts,
  235. team contact information, and other items.
  236.  
  237. IBM-ERS uses Pretty Good Privacy* (PGP*) as the digital signature mechanism for
  238. security vulnerability alerts and other distributed information.  The IBM-ERS
  239. PGP* public key is available from http://www.ers.ibm.com/team-info/pgpkey.html.
  240. "Pretty Good Privacy" and "PGP" are trademarks of Philip Zimmerman.
  241.  
  242. IBM-ERS is a Member Team of the Forum of Incident Response and Security Teams
  243. (FIRST), a global organization established to foster cooperation and response
  244. coordination among computer security teams worldwide.
  245.  
  246. Copyright 1996 International Business Machines Corporation.
  247.  
  248. The information in this document is provided as a service to customers of
  249. the IBM Emergency Response Service.  Neither International Business Machines
  250. Corporation, Integrated Systems Solutions Corporation, nor any of their
  251. employees, makes any warranty, express or implied, or assumes any legal
  252. liability or responsibility for the accuracy, completeness, or usefulness of
  253. any information, apparatus, product, or process contained herein, or
  254. represents that its use would not infringe any privately owned rights.
  255. Reference herein to any specific commercial products, process, or service by
  256. trade name, trademark, manufacturer, or otherwise, does not necessarily
  257. constitute or imply its endorsement, recommendation or favoring by IBM or
  258. its subsidiaries.  The views and opinions of authors expressed herein do not
  259. necessarily state or reflect those of IBM or its subsidiaries, and may not be
  260. used for advertising or product endorsement purposes.
  261.  
  262. The material in this security alert may be reproduced and distributed,
  263. without permission, in whole or in part, by other security incident response
  264. teams (both commercial and non-commercial), provided the above copyright is
  265. kept intact and due credit is given to IBM-ERS.
  266.  
  267. This security alert may be reproduced and distributed, without permission,
  268. in its entirety only, by any person provided such reproduction and/or
  269. distribution is performed for non-commercial purposes and with the intent of
  270. increasing the awareness of the Internet community.
  271.  
  272. - ---EXTERNAL RELEASE---EXTERNAL RELEASE---EXTERNAL RELEASE---EXTERNAL
  273. RELEASE---
  274. - --ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--ERS-ALERT--
  275.  
  276. - -- End Included Advisory --
  277.  
  278. -----BEGIN PGP SIGNATURE-----
  279. Version: 2.6.2i
  280. Comment: Finger pgp@ftp.auscert.org.au to retrieve AUSCERT's public key
  281.  
  282. iQCVAwUBMhx7xCh9+71yA2DNAQGktAP8D5SBbZRrdn9vgVzjMO6ZtapWmudSAlm+
  283. QUmYzGebC9AxndCkciZX94CqAfdg/aBJY6i6/Z0+R8DHy1ndABbQ4iGirzot9I2V
  284. TIFUktCvxdifRGR4wTKLHTwFaFdW+b0R2GDhDsF05qf5vKF27qwameQKV0Smo3tA
  285. QpK8oLlQO4s=
  286. =/JYb
  287. -----END PGP SIGNATURE-----
  288.  
  289.  
  290. -- 
  291. -------------------------------------------------------------------------------
  292.   "System Administration: It's a dirty job, but someone said I had to do it."
  293. Matthew Aldous : 019339629 : mda@mhri.edu.au : Mental Health Research Institute
  294. -------------------------------------------------------------------------------
  295.  
  296.  
  297. -- 
  298. [ route@infonexus.com ]  Editor, Phrack Magazine / Guild Corporation Chair
  299.  
  300.            the greatest trick the devil ever pulled was
  301.            convincing the world he didn't exist
  302.  
  303.