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

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