<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>228091</bug_id>
          <alias>CVE-2008-2371</alias>
          <creation_ts>2008-06-18 14:17 0000</creation_ts>
          <short_desc>dev-libs/libpcre &lt;7.7-r1 pcre_compile.c Heap-based buffer overflow (CVE-2008-2371)</short_desc>
          <delta_ts>2008-07-18 03:02:04 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Security</product>
          <component>Vulnerabilities</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <status_whiteboard>A1 [glsa]</status_whiteboard>
          
          <priority>P2</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>230039</blocked>
          
          <everconfirmed>1</everconfirmed>
          <reporter>rbu@gentoo.org</reporter>
          <assigned_to>security@gentoo.org</assigned_to>
          <cc>arm@gentoo.org</cc>
    
    <cc>loki_val@gentoo.org</cc>
    
    <cc>m68k@gentoo.org</cc>
    
    <cc>s390@gentoo.org</cc>
    
    <cc>sh@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-06-18 14:17:24 0000</bug_when>
            <thetext>** Please note that this issue is confidential and no information should be
disclosed until it is made public, see &quot;Whiteboard&quot; for a date **

Tavis Ormandy writes:

The problem is that when an option is specified at the start of a
pattern, to avoid compiling it unnecessarily into the bytecode it&apos;s
passed back up to the caller as if it was specified via pcre_compile()
options, i.e. /(?i)a|b/ == /a|b/i, and as the latter is somewhat easier
to handle, they&apos;re made equivalent. This usually works, but when a
pattern contains multiple branches, the new option is accidentally passed
back too far, so when there are multiple branches, only the first gets the
new flag, however on the second compile pass the new flag is always
set, resulting in a mismatch between the size-calculation pass and the
actual compilation pass. The result is pcre overflowing a heap buffer.

 --- pcre_compile.c~     2008-06-12 16:55:22.860930000 +0200
 +++ pcre_compile.c      2008-06-12 16:54:53.647168000 +0200
 @@ -4931,7 +4931,7 @@
                (lengthptr == NULL || *lengthptr == 2 + 2*LINK_SIZE))
             {
             cd-&gt;external_options = newoptions;
 +            options = *optionsptr = newoptions;
 -            options = newoptions;
             }
          else
             {</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-06-18 14:21:28 0000</bug_when>
            <thetext>Adding Peter as he is maintaining this package now, sorry for the spam.

Peter, please prepare an ebuild including the patch and attach it to this bug. Do not commit anything to CVS. We will do prestable testing on this bug.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>loki_val@gentoo.org</who>
            <bug_when>2008-06-18 15:24:09 0000</bug_when>
            <thetext>Created an attachment (id=157447)
libpcre-7.7-r1.ebuild

Ebuild for patch. Compiles, passes tests.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>loki_val@gentoo.org</who>
            <bug_when>2008-06-18 15:25:10 0000</bug_when>
            <thetext>Created an attachment (id=157449)
libpcre-7.7-buffer-overflow.patch

Patch as used in ebuild.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-06-18 15:58:51 0000</bug_when>
            <thetext>Do you want the 7.7 branch to go stable via this bug?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>loki_val@gentoo.org</who>
            <bug_when>2008-06-18 16:06:56 0000</bug_when>
            <thetext>(In reply to comment #4)
&gt; Do you want the 7.7 branch to go stable via this bug?
&gt; 

Yes:
7.7 is mainly a bug-fix release.
No new bugs have been filed since bump.
A bug would have been filed in 8 days anyway.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-06-18 17:25:23 0000</bug_when>
            <thetext>Arch Security Liaisons, please test the attached ebuild and report it stable on this bug.
Target keywords : &quot;alpha amd64 arm hppa ia64 m68k ppc ppc64 release s390 sh sparc x86&quot;

CC&apos;ing current Liaisons:
   alpha : yoswink
   amd64 : welp
    hppa : jer
     ppc : dertobi123
   ppc64 : corsair
 release : pva
   sparc : fmccor
     x86 : opfer</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>yoswink@gentoo.org</who>
            <bug_when>2008-06-18 23:36:38 0000</bug_when>
            <thetext>Report on alpha:
 - compiles fine
 - tests passed
 - grep built ok with prce support

Green light.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>jer@gentoo.org</who>
            <bug_when>2008-06-19 04:02:16 0000</bug_when>
            <thetext>OK for HPPA.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>corsair@gentoo.org</who>
            <bug_when>2008-06-19 05:39:20 0000</bug_when>
            <thetext>looks good on ppc64</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>welp@gentoo.org</who>
            <bug_when>2008-06-19 12:24:53 0000</bug_when>
            <thetext>Good to go on amd64.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>armin76@gentoo.org</who>
            <bug_when>2008-06-19 12:59:40 0000</bug_when>
            <thetext>Looks fine on ia64/sparc/x86</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>fauli@gentoo.org</who>
            <bug_when>2008-06-19 13:04:41 0000</bug_when>
            <thetext>(In reply to comment #11)
&gt; Looks fine on ia64/sparc/x86

 And as I know that Raul is a complete failure, I checked x86, too.  Built about 40 reverse deps and they seem to work all fine.  So Raul is right by accident. :)
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dertobi123@gentoo.org</who>
            <bug_when>2008-06-26 20:44:53 0000</bug_when>
            <thetext>looks good on ppc</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-06-30 20:51:55 0000</bug_when>
            <thetext>Lifting embargo, Peter please commit straight to stable for the arches that tested.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>loki_val@gentoo.org</who>
            <bug_when>2008-06-30 21:19:07 0000</bug_when>
            <thetext>Ebuild in tree.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-06-30 21:20:56 0000</bug_when>
            <thetext>=dev-libs/libpcre-7.7-r1
Target keywords : &quot;alpha amd64 arm hppa ia64 m68k ppc ppc64 s390 sh sparc x86&quot;
Already stabled : &quot;alpha amd64 hppa ia64 ppc ppc64 sparc x86&quot;
Missing keywords: &quot;arm m68k s390 sh&quot;
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-07-07 20:34:06 0000</bug_when>
            <thetext>Rerating A1 due to possible remote exploitation vector.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-07-07 20:35:43 0000</bug_when>
            <thetext>GLSA 200807-03</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2008-07-18 03:02:04 0000</bug_when>
            <thetext>Upstream committed a different patch, see
http://vcs.pcre.org/viewvc?view=rev&amp;revision=360
</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>157447</attachid>
            <date>2008-06-18 15:24 0000</date>
            <desc>libpcre-7.7-r1.ebuild</desc>
            <filename>libpcre-7.7-r1.ebuild</filename>
            <type>text/plain</type>
            <data encoding="base64">IyBDb3B5cmlnaHQgMTk5OS0yMDA4IEdlbnRvbyBGb3VuZGF0aW9uCiMgRGlzdHJpYnV0ZWQgdW5k
ZXIgdGhlIHRlcm1zIG9mIHRoZSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2MgojICRIZWFk
ZXI6IC92YXIvY3Zzcm9vdC9nZW50b28teDg2L2Rldi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kyIFwKCQkkKHVzZV9lbmFibGUgdW5pY29kZSB1dGY4KSAkKHVzZV9l
bmFibGUgdW5pY29kZSB1bmljb2RlLXByb3BlcnRpZXMpIFwKCQkkKHVzZV9lbmFibGUgY3h4IGNw
cCkgXAoJCSQodXNlX2VuYWJsZSB6bGliIHBjcmVncmVwLWxpYnopIFwKCQkkKHVzZV9lbmFibGUg
YnppcDIgcGNyZWdyZXAtbGliYnoyKSBcCgkJLS1lbmFibGUtc3RhdGljIFwKCQktLWh0bWxkaXI9
L3Vzci9zaGFyZS9kb2MvJHtQRn0vaHRtbCBcCgkJLS1kb2NkaXI9L3Vzci9zaGFyZS9kb2MvJHtQ
Rn0gXAoJCXx8IGRpZSAiZWNvbmYgZmFpbGVkIgoJZW1ha2UgYWxsIHx8IGRpZSAiZW1ha2UgZmFp
bGVkIgp9CgpzcmNfaW5zdGFsbCgpIHsKCWVtYWtlIERFU1RESVI9IiR7RH0iIGluc3RhbGwgfHwg
ZGllICJtYWtlIGluc3RhbGwgZmFpbGVkIgoKCWRvZG9jIGRvYy8qLnR4dCBBVVRIT1JTCgl1c2Ug
ZG9jICYmIGRvaHRtbCBkb2MvaHRtbC8qCn0K
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>157449</attachid>
            <date>2008-06-18 15:25 0000</date>
            <desc>libpcre-7.7-buffer-overflow.patch</desc>
            <filename>libpcre-7.7-buffer-overflow.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtTnJVNSBwY3JlLTcuNy5vcmlnL3BjcmVfY29tcGlsZS5jIHBjcmUtNy43L3BjcmVfY29t
cGlsZS5jCi0tLSBwY3JlLTcuNy5vcmlnL3BjcmVfY29tcGlsZS5jCTIwMDgtMDYtMTggMTc6MDg6
NDkuMDAwMDAwMDAwICswMjAwCisrKyBwY3JlLTcuNy9wY3JlX2NvbXBpbGUuYwkyMDA4LTA2LTE4
IDE3OjExOjA0LjAwMDAwMDAwMCArMDIwMApAQCAtNDkyOSwxMSArNDkyOSwxMSBAQAogICAgICAg
ICAgIHsKICAgICAgICAgICBpZiAoY29kZSA9PSBjZC0+c3RhcnRfY29kZSArIDEgKyBMSU5LX1NJ
WkUgJiYKICAgICAgICAgICAgICAgIChsZW5ndGhwdHIgPT0gTlVMTCB8fCAqbGVuZ3RocHRyID09
IDIgKyAyKkxJTktfU0laRSkpCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICBjZC0+ZXh0ZXJu
YWxfb3B0aW9ucyA9IG5ld29wdGlvbnM7Ci0gICAgICAgICAgICBvcHRpb25zID0gbmV3b3B0aW9u
czsKKyAgICAgICAgICAgIG9wdGlvbnMgPSAqb3B0aW9uc3B0ciA9IG5ld29wdGlvbnM7CiAgICAg
ICAgICAgICB9CiAgICAgICAgICBlbHNlCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICBpZiAo
KG9wdGlvbnMgJiBQQ1JFX0lNUykgIT0gKG5ld29wdGlvbnMgJiBQQ1JFX0lNUykpCiAgICAgICAg
ICAgICAgIHsK
</data>        

          </attachment>
    </bug>

</bugzilla>