home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / general / cert0149.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  29.0 KB  |  818 lines

  1.  
  2. -----BEGIN PGP SIGNED MESSAGE-----
  3.  
  4. =============================================================================
  5. CERT* Advisory CA-97.17
  6. Original issue date: May 29, 1997
  7. Last revised: June 9, 1997
  8.               Appendix A - added information from Sun Microsystems, Inc.
  9.  
  10.               A complete revision history is at the end of this file.
  11.  
  12. Topic: Vulnerability in suidperl (sperl)
  13. - -----------------------------------------------------------------------------
  14.  
  15. The CERT Coordination Center has received reports of a buffer overflow
  16. condition in suidperl built from Perl 4.n and Perl 5.n distributions on UNIX
  17. systems. By calling this program with appropriately crafted parameters,
  18. unauthorized local users can execute arbitrary commands as root. This
  19. vulnerability is being actively exploited.
  20.  
  21. The CERT/CC team recommends installing a vendor patch if one is available (see
  22. Section III.B). Until you can do so, we recommend disabling suidperl (Section
  23. III.A). Two other alternatives are to install suidperl or sperl from version
  24. 5.003 source code along with the patch provided in Appendix B of this
  25. advisory (see also Section III.C), or upgrade to Perl version 5.004 (Section
  26. III.D). Note that Perl4 is no longer supported.
  27.  
  28. We will update this advisory as we receive additional information.
  29. Please check our advisory files regularly for updates that relate to your site.
  30.  
  31. - -----------------------------------------------------------------------------
  32.  
  33. I.   Description
  34.  
  35.      On some systems, setuid and setgid scripts (scripts written in the C
  36.      shell, Bourne shell, or Perl, for example, with the set user or group ID
  37.      permissions enabled) are insecure due to a race condition in the
  38.      kernel. For those systems, Perl versions 4 and 5 attempt to work around
  39.      this vulnerability with a special program named suidperl, also known as
  40.      sperl. This program attempts to emulate the set-user-ID and set-group-ID
  41.      features of the kernel.
  42.  
  43.      There is a buffer overflow condition in suidperl built from Perl 4.n and
  44.      Perl 5.n distributions earlier than version 5.004. If this program is
  45.      called with appropriately crafted parameters, an attacker can execute
  46.      arbitrary commands as root. This vulnerability is being actively
  47.      exploited.
  48.  
  49. II.  Impact
  50.  
  51.      Users executing Perl scripts with the setuid bit set can execute
  52.      arbitrary commands with the effective uid of the owner of the Perl
  53.      script. Attackers can execute commands as root.
  54.  
  55.  
  56. III. Solution
  57.  
  58.      Use the command in Section A to help you determine if your system is
  59.      vulnerable and, if it is, to (optionally) disable the suidperl and sperl
  60.      programs (see Section A). If you find that your system is vulnerable,
  61.      replace the suidperl and sperl programs with new versions.
  62.  
  63.      Section B describes how to do that if your site uses versions of suidperl
  64.      and sperl that are provided as part of a vendor-supplied distribution.
  65.      Sites that installed suidperl and sperl programs themselves from the Perl
  66.      source distribution should patch the distribution as described in Section
  67.      C or upgrade to version 5.004 as described in Section D. Note that Perl4
  68.      is no longer supported.
  69.  
  70.      A. Determine if your system is vulnerable and disable vulnerable programs
  71.  
  72.         To determine if a system is vulnerable to this problem and to disable
  73.         the programs that are believed to be vulnerable, use the following
  74.         find command or a variant. Consult your local system documentation to
  75.         determine how to tailor the find program on your system.
  76.  
  77.         After you have run this command on all your systems, they will no
  78.         longer be vulnerable. Note that after disabling the suidperl and sperl
  79.         programs, they will no longer be able to emulate the set-user-ID and
  80.         set-group-ID features of the kernel.
  81.  
  82.         You will need to run the find command on each system you maintain
  83.         because the command examines files on the local disk only. Substitute
  84.         the names of your local file systems for FILE_SYSTEM_NAMES in the
  85.         example. Example local file system names are /, /usr, and /var.
  86.         You must do this as root.
  87.  
  88.         Note that this is one long command, though we have separated
  89.         it onto five lines using back-slashes.
  90.  
  91.              find FILE_SYSTEM_NAMES -xdev -type f -user root \
  92.                     \( -name 'sperl4.[0-9][0-9][0-9]' \
  93.                     -o -name 'sperl5.00[0-3]' \
  94.                     -o -name 'suidperl' \) \
  95.                     -perm -04000 -print -ok chmod ug-s '{}' \;
  96.  
  97.         This command will find all files on a system that are
  98.             - only in the file system you name (FILE_SYSTEM_NAMES -xdev)
  99.             - regular files (-type f)
  100.             - owned by root (-user root)
  101.             - named appropriately (-name 'sperl4.[0-9][0-9][0-9]'
  102.                                     -o -name 'sperl5.00[0-3]'
  103.                                     -o -name 'suidperl')
  104.             - setuid root (-perm -04000)
  105.  
  106.         Once found, those files will
  107.             - have their names printed (-print)
  108.             - have their modes changed, but only if you type `y'
  109.               in response to the prompt (-ok chown ug-s '{}' \;)
  110.  
  111.  
  112.      B. Obtain and install the appropriate patch from your vendor
  113.  
  114.         If your vendor ships suidperl or sperl, you may be vulnerable and need
  115.         a patch. Appendix A contains information provided by the following
  116.         vendors. If your vendor is not on this list, please contact the vendor
  117.         directly.
  118.  
  119.                 Berkeley Software Design, Inc. (BSDI)
  120.                 Cray Research - A Silicon Graphics Company
  121.                 Data General Corporation
  122.                 Hewlett-Packard Company
  123.                 IBM Corporation
  124.                 Linux
  125.                 The Santa Cruz Operation, Inc. (SCO)
  126.                 Silicon Graphics, Inc. (SGI)
  127.  
  128.         Until you can install a patch, we recommend disabling suidperl.
  129.         The find command above will help you do that. If you need
  130.         suidperl or sperl, see the alternatives in Sections C and D below.
  131.  
  132.  
  133.      C. Install suidperl or sperl from 5.003 source code and apply a patch.
  134.         Follow the instructions below, which were provided by Chip Salzenberg.
  135.  
  136.         If you would like to keep using setuid Perl scripts, fix Perl
  137.         yourself by following these steps:
  138.  
  139.         1. Go to your Perl 5.003 source directory, or else obtain a fresh
  140.            Perl 5.003 distribution from
  141.  
  142.               http://www.perl.com/CPAN/src/5.0/perl5.003.tar.gz
  143.  
  144.            or another CPAN archive accessible to you.
  145.  
  146.            This file is approximately 1.5 megabytes in size.
  147.  
  148.         2. Using the "patch" program, apply the patch that is enclosed
  149.            below in Appendix B.
  150.  
  151.         3. Build and install the patched Perl 5.003. (If you have never
  152.            built Perl before, be sure to read the "INSTALL" file first.)
  153.  
  154.         Perl 5.003 binaries that have had this patch applied, and therefore
  155.         are safe from all known attacks, can be identified by the
  156.         output of the "perl -v" command: the "locally applied patches" list
  157.         will include "SUIDBUF - Buffer overflow fixes for suidperl
  158.         security".
  159.  
  160.  
  161.      D. Install suidperl or sperl from 5.004 source code (no patch needed).
  162.  
  163.         If you would like to upgrade to Perl version 5.004, follow these
  164.         steps:
  165.  
  166.         1. Obtain a fresh Perl 5.004 distribution from
  167.  
  168.               http://www.perl.com/CPAN/src/5.0/perl5.004.tar.gz
  169.  
  170.            or another CPAN archive accessible to you.
  171.  
  172.            This file is approximately 2.5 megabytes in size.
  173.  
  174.         2. Build and install Perl 5.004 according to the instructions
  175.            given in the "INSTALL" file. Do NOT apply the patch.
  176.  
  177.            Perl 5.004 binaries, which are safe from all known attacks, can be
  178.            identified by the output of the "perl -v" command: it should say
  179.            "This is perl, version 5.004". (Unlike the 5.003 patch mentioned
  180.            in Section C, the "locally applied patches" list will NOT include
  181.            "SUIDBUF - Buffer overflow fixes for suidperl security". The fact
  182.            that it is version 5.004 is sufficient in this case.)
  183.  
  184.  
  185. ...........................................................................
  186.  
  187. Appendix A - Vendor Information
  188.  
  189. Below is a list of the vendors who have provided information for this
  190. advisory. We will update this appendix as we receive additional information.
  191. If you do not see your vendor's name, the CERT/CC did not hear from that
  192. vendor. Please contact the vendor directly.
  193.  
  194.  
  195. Berkeley Software Design, Inc. (BSDI)
  196. =====================================
  197.   BSD/OS is vulnerable to the suidperl (sperl) buffer overflow problem. We
  198.   will be releasing a patch for BSDI 3.0 and perl 5.003 and are currently
  199.   working on patches for BSD/OS 3.0 and Perl 4.036. We will also be developing
  200.   patches for the perl versions shipped with BSD/OS 2.1.
  201.  
  202.  
  203. Cray Research - A Silicon Graphics Company
  204. ==========================================
  205.   Cray Research does not ship perl as part of either Unicos or Unicos/mk.
  206.  
  207.  
  208. Data General Corporation
  209. ========================
  210.   The only perl executables that are shipped with DG/UX are:
  211.  
  212.   /bin/perl
  213.  
  214.   and
  215.  
  216.   /bin/perl5 /* in R420 */
  217.  
  218.   These are not set uid programs.
  219.  
  220.   Therefore,
  221.   No versions of DG/UX are vulnerable to this problem.
  222.  
  223.  
  224. Hewlett-Packard Company
  225. =======================
  226.   HP does not ship this product.
  227.  
  228.  
  229. IBM Corporation
  230. ===============
  231.   AIX versions do not have Perl as part of the standard product.
  232.   However, the SP2's PSSP software does contain suidperl, but the
  233.   program is not installed with the setuid bit set.
  234.  
  235.   IBM and AIX are registered trademarks of International Business Machines
  236.   Corporation.
  237.  
  238.  
  239. Linux
  240. =====
  241.   Red Hat 4.2 is not vulnerable
  242.   Red Hat 4.1/4.0 you can get the upgraded RPM from ftp.redhat.com
  243.  
  244.   If you wish to check whether you have the fixed perl run perl -v and
  245.   check for
  246.  
  247.         Locally applied patches:
  248.           SUIDBUF - Buffer overflow fixes for suidperl security
  249.  
  250.  
  251. The Santa Cruz Operation, Inc. (SCO)
  252. ====================================
  253.   suidperl is not included in any SCO products.
  254.  
  255.   SCO CMW+ and SCO OpenServer do not have kernel support for setuid
  256.   scripts, but you may have installed suidperl in order to emulate
  257.   that functionality - in that case you should replace your version of
  258.   perl with version 5.004, or patch your source code as noted in this
  259.   advisory.
  260.  
  261.   SCO UnixWare does have safe kernel support for setuid scripts so
  262.   that suidperl is not necessary.  If you have installed a version
  263.   of perl that includes suidperl, you should remove suidperl and
  264.   install a version of perl built so as not to require it.
  265.  
  266.  
  267. Silicon Graphics, Inc. (SGI)
  268. =============================
  269.   At this time, Silicon Graphics does not have any public information for
  270.   this suidperl/sperl issue.  Silicon Graphics has communicated with
  271.   CERT and other external security parties and is actively investigating
  272.   this issue.   When more Silicon Graphics information (including any
  273.   possible patches) is available for release, that information will
  274.   be released via the SGI security mailing list, wiretap.
  275.  
  276.   For subscribing to the wiretap mailing list and other SGI security
  277.   related information, please refer to the Silicon Graphics Security
  278.   Headquarters website located at:
  279.  
  280.         http://www.sgi.com/Support/Secur/security.html
  281.  
  282.  
  283. Sun Microsystems, Inc.
  284. ======================
  285. Sun does not ship this product.
  286.  
  287. ...........................................................................
  288.  
  289. Appendix B - Source Code Patch Information
  290.  
  291. The following patch information has been supplied by Chip Salzenberg. If you
  292. built suidperl or sperl from 5.003 source code, we encouraged you to apply
  293. this patch (see the explanation in Section III.C above).
  294.  
  295.  
  296. Patch follows.
  297.  
  298. - --------------------------------------------------------------------------
  299.  
  300. Index: patchlevel.h
  301. ***************
  302. *** 41,42 ****
  303. - --- 41,43 ----
  304. +       ,"SUIDBUF - Buffer overflow fixes for suidperl security"
  305.         ,NULL
  306.   };
  307.  
  308. Index: perl.c
  309. *************** char *s;
  310. *** 1212,1216 ****
  311.   #  endif
  312.   #endif
  313. !       fputs("\n\t+ suidperl security patch", stdout);
  314.         fputs("\n\nCopyright 1987-1996, Larry Wall\n",stdout);
  315.   #ifdef MSDOS
  316. - --- 1212,1216 ----
  317.   #  endif
  318.   #endif
  319. !       fputs("\n\t+ two suidperl security patches", stdout);
  320.         fputs("\n\nCopyright 1987-1996, Larry Wall\n",stdout);
  321.   #ifdef MSDOS
  322.  
  323. Index: gv.c
  324. *************** gv_fetchfile(name)
  325. *** 59,67 ****
  326.   char *name;
  327.   {
  328. !     char tmpbuf[1200];
  329.       GV *gv;
  330.  
  331. !     sprintf(tmpbuf,"::_<%s", name);
  332.       gv = gv_fetchpv(tmpbuf, TRUE, SVt_PVGV);
  333.       sv_setpv(GvSV(gv), name);
  334.       if (*name == '/' && (instr(name,"/lib/") || instr(name,".pm")))
  335. - --- 59,80 ----
  336.   char *name;
  337.   {
  338. !     char smallbuf[256];
  339. !     char *tmpbuf;
  340. !     STRLEN tmplen;
  341.       GV *gv;
  342.  
  343. !     tmplen = strlen(name) + 4;
  344. !     if (tmplen < sizeof smallbuf)
  345. !       tmpbuf = smallbuf;
  346. !     else
  347. !       New(603, tmpbuf, tmplen + 1, char);
  348. !     tmpbuf[0] = ':';
  349. !     tmpbuf[1] = ':';
  350. !     tmpbuf[2] = '_';
  351. !     tmpbuf[3] = '<';
  352. !     strcpy(tmpbuf + 4, name);
  353.       gv = gv_fetchpv(tmpbuf, TRUE, SVt_PVGV);
  354. +     if (tmpbuf != smallbuf)
  355. +       Safefree(tmpbuf);
  356.       sv_setpv(GvSV(gv), name);
  357.       if (*name == '/' && (instr(name,"/lib/") || instr(name,".pm")))
  358.  
  359. Index: toke.c
  360. *************** static char *scan_const _((char *start))
  361. *** 22,26 ****
  362.   static char *scan_formline _((char *s));
  363.   static char *scan_heredoc _((char *s));
  364. ! static char *scan_ident _((char *s, char *send, char *dest, I32 ck_uni));
  365.   static char *scan_inputsymbol _((char *start));
  366.   static char *scan_pat _((char *start));
  367. - --- 22,27 ----
  368.   static char *scan_formline _((char *s));
  369.   static char *scan_heredoc _((char *s));
  370. ! static char *scan_ident _((char *s, char *send, char *dest, STRLEN destlen,
  371. !                          I32 ck_uni));
  372.   static char *scan_inputsymbol _((char *start));
  373.   static char *scan_pat _((char *start));
  374. *************** static char *scan_str _((char *start));
  375. *** 28,32 ****
  376.   static char *scan_subst _((char *start));
  377.   static char *scan_trans _((char *start));
  378. ! static char *scan_word _((char *s, char *dest, int allow_package, STRLEN *slp));
  379.   static char *skipspace _((char *s));
  380.   static void checkcomma _((char *s, char *name, char *what));
  381. - --- 29,34 ----
  382.   static char *scan_subst _((char *start));
  383.   static char *scan_trans _((char *start));
  384. ! static char *scan_word _((char *s, char *dest, STRLEN destlen,
  385. !                         int allow_package, STRLEN *slp));
  386.   static char *skipspace _((char *s));
  387.   static void checkcomma _((char *s, char *name, char *what));
  388. *************** static char * filter_gets _((SV *sv, FIL
  389. *** 47,50 ****
  390. - --- 49,54 ----
  391.   static void restore_rsfp _((void *f));
  392.  
  393. + static char too_long[] = "Identifier too long";
  394. +
  395.   /* The following are arranged oddly so that the guard on the switch statement
  396.    * can get by with a single comparison (if the compiler is smart enough).
  397. *************** int allow_tick;
  398. *** 475,479 ****
  399.         (allow_tick && *s == '\'') )
  400.       {
  401. !       s = scan_word(s, tokenbuf, allow_pack, &len);
  402.         if (check_keyword && keyword(tokenbuf, len))
  403.             return start;
  404. - --- 479,483 ----
  405.         (allow_tick && *s == '\'') )
  406.       {
  407. !       s = scan_word(s, tokenbuf, sizeof tokenbuf, allow_pack, &len);
  408.         if (check_keyword && keyword(tokenbuf, len))
  409.             return start;
  410. *************** register char *s;
  411. *** 847,851 ****
  412.         unsigned char un_char = 0, last_un_char;
  413.         char *send = strchr(s,']');
  414. !       char tmpbuf[512];
  415.  
  416.         if (!send)              /* has to be an expression */
  417. - --- 851,855 ----
  418.         unsigned char un_char = 0, last_un_char;
  419.         char *send = strchr(s,']');
  420. !       char tmpbuf[sizeof tokenbuf * 4];
  421.  
  422.         if (!send)              /* has to be an expression */
  423. *************** register char *s;
  424. *** 872,876 ****
  425.                 weight -= seen[un_char] * 10;
  426.                 if (isALNUM(s[1])) {
  427. !                   scan_ident(s,send,tmpbuf,FALSE);
  428.                     if ((int)strlen(tmpbuf) > 1 && gv_fetchpv(tmpbuf,FALSE, SVt_PV))
  429.                         weight -= 100;
  430. - --- 876,880 ----
  431.                 weight -= seen[un_char] * 10;
  432.                 if (isALNUM(s[1])) {
  433. !                   scan_ident(s, send, tmpbuf, sizeof tmpbuf, FALSE);
  434.                     if ((int)strlen(tmpbuf) > 1 && gv_fetchpv(tmpbuf,FALSE, SVt_PV))
  435.                         weight -= 100;
  436. *************** GV *gv;
  437. *** 942,946 ****
  438.   {
  439.       char *s = start + (*start == '$');
  440. !     char tmpbuf[1024];
  441.       STRLEN len;
  442.       GV* indirgv;
  443. - --- 946,950 ----
  444.   {
  445.       char *s = start + (*start == '$');
  446. !     char tmpbuf[sizeof tokenbuf];
  447.       STRLEN len;
  448.       GV* indirgv;
  449. *************** GV *gv;
  450. *** 952,956 ****
  451.             gv = 0;
  452.       }
  453. !     s = scan_word(s, tmpbuf, TRUE, &len);
  454.       if (*start == '$') {
  455.         if (gv || last_lop_op == OP_PRINT || isUPPER(*tokenbuf))
  456. - --- 956,960 ----
  457.             gv = 0;
  458.       }
  459. !     s = scan_word(s, tmpbuf, sizeof tmpbuf, TRUE, &len);
  460.       if (*start == '$') {
  461.         if (gv || last_lop_op == OP_PRINT || isUPPER(*tokenbuf))
  462. *************** yylex()
  463. *** 1629,1633 ****
  464.       case '*':
  465.         if (expect != XOPERATOR) {
  466. !           s = scan_ident(s, bufend, tokenbuf, TRUE);
  467.             expect = XOPERATOR;
  468.             force_ident(tokenbuf, '*');
  469. - --- 1633,1637 ----
  470.       case '*':
  471.         if (expect != XOPERATOR) {
  472. !           s = scan_ident(s, bufend, tokenbuf, sizeof tokenbuf, TRUE);
  473.             expect = XOPERATOR;
  474.             force_ident(tokenbuf, '*');
  475. *************** yylex()
  476. *** 1645,1649 ****
  477.       case '%':
  478.         if (expect != XOPERATOR) {
  479. !           s = scan_ident(s, bufend, tokenbuf + 1, TRUE);
  480.             if (tokenbuf[1]) {
  481.                 expect = XOPERATOR;
  482. - --- 1649,1653 ----
  483.       case '%':
  484.         if (expect != XOPERATOR) {
  485. !           s = scan_ident(s, bufend, tokenbuf + 1, sizeof tokenbuf - 1, TRUE);
  486.             if (tokenbuf[1]) {
  487.                 expect = XOPERATOR;
  488. *************** yylex()
  489. *** 1748,1752 ****
  490.                 s++;
  491.             if (s < bufend && isALPHA(*s)) {
  492. !               d = scan_word(s, tokenbuf, FALSE, &len);
  493.                 while (d < bufend && (*d == ' ' || *d == '\t'))
  494.                     d++;
  495. - --- 1752,1756 ----
  496.                 s++;
  497.             if (s < bufend && isALPHA(*s)) {
  498. !               d = scan_word(s, tokenbuf, sizeof tokenbuf, FALSE, &len);
  499.                 while (d < bufend && (*d == ' ' || *d == '\t'))
  500.                     d++;
  501. *************** yylex()
  502. *** 1847,1851 ****
  503.         }
  504.  
  505. !       s = scan_ident(s-1, bufend, tokenbuf, TRUE);
  506.         if (*tokenbuf) {
  507.             expect = XOPERATOR;
  508. - --- 1851,1855 ----
  509.         }
  510.  
  511. !       s = scan_ident(s - 1, bufend, tokenbuf, sizeof tokenbuf, TRUE);
  512.         if (*tokenbuf) {
  513.             expect = XOPERATOR;
  514. *************** yylex()
  515. *** 1956,1960 ****
  516.       case '$':
  517.         if (s[1] == '#'  && (isALPHA(s[2]) || strchr("_{$:", s[2]))) {
  518. !           s = scan_ident(s+1, bufend, tokenbuf+1, FALSE);
  519.             if (expect == XOPERATOR) {
  520.                 if (lex_formbrack && lex_brackets == lex_formbrack) {
  521. - --- 1960,1965 ----
  522.       case '$':
  523.         if (s[1] == '#'  && (isALPHA(s[2]) || strchr("_{$:", s[2]))) {
  524. !           s = scan_ident(s + 1, bufend, tokenbuf + 1, sizeof tokenbuf - 1,
  525. !                          FALSE);
  526.             if (expect == XOPERATOR) {
  527.                 if (lex_formbrack && lex_brackets == lex_formbrack) {
  528. *************** yylex()
  529. *** 1982,1986 ****
  530.             TOKEN(DOLSHARP);
  531.         }
  532. !       s = scan_ident(s, bufend, tokenbuf+1, FALSE);
  533.         if (expect == XOPERATOR) {
  534.             if (lex_formbrack && lex_brackets == lex_formbrack) {
  535. - --- 1987,1991 ----
  536.             TOKEN(DOLSHARP);
  537.         }
  538. !       s = scan_ident(s, bufend, tokenbuf + 1, sizeof tokenbuf - 1, FALSE);
  539.         if (expect == XOPERATOR) {
  540.             if (lex_formbrack && lex_brackets == lex_formbrack) {
  541. *************** yylex()
  542. *** 2016,2024 ****
  543.                 if (*s == '{' && strEQ(tokenbuf, "$SIG") &&
  544.                   (t = strchr(s,'}')) && (t = strchr(t,'='))) {
  545. !                   char tmpbuf[1024];
  546.                     STRLEN len;
  547.                     for (t++; isSPACE(*t); t++) ;
  548.                     if (isIDFIRST(*t)) {
  549. !                       t = scan_word(t, tmpbuf, TRUE, &len);
  550.                         if (*t != '(' && perl_get_cv(tmpbuf, FALSE))
  551.                             warn("You need to quote \"%s\"", tmpbuf);
  552. - --- 2021,2029 ----
  553.                 if (*s == '{' && strEQ(tokenbuf, "$SIG") &&
  554.                   (t = strchr(s,'}')) && (t = strchr(t,'='))) {
  555. !                   char tmpbuf[sizeof tokenbuf];
  556.                     STRLEN len;
  557.                     for (t++; isSPACE(*t); t++) ;
  558.                     if (isIDFIRST(*t)) {
  559. !                       t = scan_word(t, tmpbuf, sizeof tmpbuf, TRUE, &len);
  560.                         if (*t != '(' && perl_get_cv(tmpbuf, FALSE))
  561.                             warn("You need to quote \"%s\"", tmpbuf);
  562. *************** yylex()
  563. *** 2093,2097 ****
  564.  
  565.       case '@':
  566. !       s = scan_ident(s, bufend, tokenbuf+1, FALSE);
  567.         if (expect == XOPERATOR)
  568.             no_op("Array",s);
  569. - --- 2098,2102 ----
  570.  
  571.       case '@':
  572. !       s = scan_ident(s, bufend, tokenbuf + 1, sizeof tokenbuf - 1, FALSE);
  573.         if (expect == XOPERATOR)
  574.             no_op("Array",s);
  575. *************** yylex()
  576. *** 2129,2133 ****
  577.                         : !GvHV(gv) )))
  578.             {
  579. !               char tmpbuf[1024];
  580.                 sprintf(tmpbuf, "Literal @%s now requires backslash",tokenbuf+1);
  581.                 yyerror(tmpbuf);
  582. - --- 2134,2138 ----
  583.                         : !GvHV(gv) )))
  584.             {
  585. !               char tmpbuf[sizeof tokenbuf + 40];
  586.                 sprintf(tmpbuf, "Literal @%s now requires backslash",tokenbuf+1);
  587.                 yyerror(tmpbuf);
  588. *************** yylex()
  589. *** 2293,2297 ****
  590.         keylookup:
  591.         bufptr = s;
  592. !       s = scan_word(s, tokenbuf, FALSE, &len);
  593.         
  594.         if (*s == ':' && s[1] == ':' && strNE(tokenbuf, "CORE"))
  595. - --- 2298,2302 ----
  596.         keylookup:
  597.         bufptr = s;
  598. !       s = scan_word(s, tokenbuf, sizeof tokenbuf, FALSE, &len);
  599.         
  600.         if (*s == ':' && s[1] == ':' && strNE(tokenbuf, "CORE"))
  601. *************** yylex()
  602. *** 2338,2342 ****
  603.  
  604.                 if (*s == '\'' || *s == ':' && s[1] == ':') {
  605. !                   s = scan_word(s, tokenbuf + len, TRUE, &len);
  606.                     if (!len)
  607.                         croak("Bad name after %s::", tokenbuf);
  608. - --- 2343,2348 ----
  609.  
  610.                 if (*s == '\'' || *s == ':' && s[1] == ':') {
  611. !                   s = scan_word(s, tokenbuf + len, sizeof tokenbuf - len,
  612. !                                 TRUE, &len);
  613.                     if (!len)
  614.                         croak("Bad name after %s::", tokenbuf);
  615. *************** yylex()
  616. *** 2557,2561 ****
  617.                 s += 2;
  618.                 d = s;
  619. !               s = scan_word(s, tokenbuf, FALSE, &len);
  620.                 tmp = keyword(tokenbuf, len);
  621.                 if (tmp < 0)
  622. - --- 2563,2567 ----
  623.                 s += 2;
  624.                 d = s;
  625. !               s = scan_word(s, tokenbuf, sizeof tokenbuf, FALSE, &len);
  626.                 tmp = keyword(tokenbuf, len);
  627.                 if (tmp < 0)
  628. *************** yylex()
  629. *** 3244,3250 ****
  630.  
  631.             if (isIDFIRST(*s) || *s == '\'' || *s == ':') {
  632. !               char tmpbuf[128];
  633.                 expect = XBLOCK;
  634. !               d = scan_word(s, tmpbuf, TRUE, &len);
  635.                 if (strchr(tmpbuf, ':'))
  636.                     sv_setpv(subname, tmpbuf);
  637. - --- 3250,3256 ----
  638.  
  639.             if (isIDFIRST(*s) || *s == '\'' || *s == ':') {
  640. !               char tmpbuf[sizeof tokenbuf];
  641.                 expect = XBLOCK;
  642. !               d = scan_word(s, tmpbuf, sizeof tmpbuf, TRUE, &len);
  643.                 if (strchr(tmpbuf, ':'))
  644.                     sv_setpv(subname, tmpbuf);
  645. *************** char *what;
  646. *** 4091,4102 ****
  647.  
  648.   static char *
  649. ! scan_word(s, dest, allow_package, slp)
  650.   register char *s;
  651.   char *dest;
  652.   int allow_package;
  653.   STRLEN *slp;
  654.   {
  655.       register char *d = dest;
  656.       for (;;) {
  657.         if (isALNUM(*s))
  658.             *d++ = *s++;
  659. - --- 4097,4112 ----
  660.  
  661.   static char *
  662. ! scan_word(s, dest, destlen, allow_package, slp)
  663.   register char *s;
  664.   char *dest;
  665. + STRLEN destlen;
  666.   int allow_package;
  667.   STRLEN *slp;
  668.   {
  669.       register char *d = dest;
  670. +     register char *e = d + destlen - 3;  /* two-character token, ending NUL */
  671.       for (;;) {
  672. +       if (d >= e)
  673. +           croak(too_long);
  674.         if (isALNUM(*s))
  675.             *d++ = *s++;
  676. *************** STRLEN *slp;
  677. *** 4119,4129 ****
  678.  
  679.   static char *
  680. ! scan_ident(s,send,dest,ck_uni)
  681.   register char *s;
  682.   register char *send;
  683.   char *dest;
  684.   I32 ck_uni;
  685.   {
  686.       register char *d;
  687.       char *bracket = 0;
  688.       char funny = *s++;
  689. - --- 4129,4141 ----
  690.  
  691.   static char *
  692. ! scan_ident(s, send, dest, destlen, ck_uni)
  693.   register char *s;
  694.   register char *send;
  695.   char *dest;
  696. + STRLEN destlen;
  697.   I32 ck_uni;
  698.   {
  699.       register char *d;
  700. +     register char *e;
  701.       char *bracket = 0;
  702.       char funny = *s++;
  703. *************** I32 ck_uni;
  704. *** 4134,4143 ****
  705.         s = skipspace(s);
  706.       d = dest;
  707.       if (isDIGIT(*s)) {
  708. !       while (isDIGIT(*s))
  709.             *d++ = *s++;
  710.       }
  711.       else {
  712.         for (;;) {
  713.             if (isALNUM(*s))
  714.                 *d++ = *s++;
  715. - --- 4146,4161 ----
  716.         s = skipspace(s);
  717.       d = dest;
  718. +     e = d + destlen - 3;      /* two-character token, ending NUL */
  719.       if (isDIGIT(*s)) {
  720. !       while (isDIGIT(*s)) {
  721. !           if (d >= e)
  722. !               croak(too_long);
  723.             *d++ = *s++;
  724. +       }
  725.       }
  726.       else {
  727.         for (;;) {
  728. +           if (d >= e)
  729. +               croak(too_long);
  730.             if (isALNUM(*s))
  731.                 *d++ = *s++;
  732.  
  733. - --------------------------------------------------------------------------
  734.  
  735. End of patch.
  736.  
  737. - -----------------------------------------------------------------------------
  738.  
  739. The CERT Coordination Center staff thanks Chip Salzenberg for supplying a fix,
  740. Larry Wall for tweaking the fix, and Warner Losh for his work on patches.
  741.  
  742. - -----------------------------------------------------------------------------
  743.  
  744. If you believe that your system has been compromised, contact the CERT
  745. Coordination Center or your representative in the Forum of Incident Response
  746. and Security Teams (see http://www.first.org/team-info/)
  747.  
  748.  
  749. CERT/CC Contact Information
  750. - ----------------------------
  751. Email    cert@cert.org
  752.  
  753. Phone    +1 412-268-7090 (24-hour hotline)
  754.                 CERT personnel answer 8:30-5:00 p.m. EST(GMT-5) / EDT(GMT-4)
  755.                 and are on call for emergencies during other hours.
  756.  
  757. Fax      +1 412-268-6989
  758.  
  759. Postal address
  760.          CERT Coordination Center
  761.          Software Engineering Institute
  762.          Carnegie Mellon University
  763.          Pittsburgh PA 15213-3890
  764.          USA
  765.  
  766. Using encryption
  767.    We strongly urge you to encrypt sensitive information sent by email. We can
  768.    support a shared DES key or PGP. Contact the CERT/CC for more information.
  769.    Location of CERT PGP key
  770.          ftp://info.cert.org/pub/CERT_PGP.key
  771.  
  772. Getting security information
  773.    CERT publications and other security information are available from
  774.         http://www.cert.org/
  775.         ftp://info.cert.org/pub/
  776.  
  777.    CERT advisories and bulletins are also posted on the USENET newsgroup
  778.         comp.security.announce
  779.  
  780.    To be added to our mailing list for advisories and bulletins, send
  781.    email to
  782.         cert-advisory-request@cert.org
  783.    In the subject line, type
  784.         SUBSCRIBE  your-email-address
  785.  
  786. - ---------------------------------------------------------------------------
  787. * Registered U.S. Patent and Trademark Office.
  788.  
  789. Copyright 1997 Carnegie Mellon University
  790. This material may be reproduced and distributed without permission provided
  791. it is used for noncommercial purposes and the copyright statement is
  792. included.
  793.  
  794. The CERT Coordination Center is part of the Software Engineering Institute
  795. (SEI). The SEI is sponsored by the U.S. Department of Defense.
  796. - ---------------------------------------------------------------------------
  797.  
  798. This file: ftp://info.cert.org/pub/cert_advisories/CA-97.17.sperl
  799.            http://www.cert.org
  800.                click on "CERT Advisories"
  801.  
  802.  
  803. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  804. Revision history
  805.  
  806. June 9, 1997  Appendix A - added information from Sun Microsystems, Inc.
  807.  
  808. -----BEGIN PGP SIGNATURE-----
  809. Version: 2.6.2
  810.  
  811. iQCVAwUBM5xeTHVP+x0t4w7BAQHQlwQAgMtgobPBgzd20coYAKI7xc6KvDhV11IA
  812. dQXM4UPfG0gxGZSwkipTQOvK0sVCSaMdBNdkfOvdMZIe11rHahu3KCmAM8yst28J
  813. zATDFXpCdASj2yDvJdblJgtSamBdUTn2d2IjXKhu0ygNZZEv9Y8YiuRjXXF3NwJp
  814. PFLiqGlMI+4=
  815. =faTa
  816. -----END PGP SIGNATURE-----
  817.  
  818.