RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1095602 - tomcat6 security patch tomcat6-6.0.24-CVE-2013-4322 typo results in application crash with EOFException
Summary: tomcat6 security patch tomcat6-6.0.24-CVE-2013-4322 typo results in applicati...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: tomcat6
Version: 6.5
Hardware: Unspecified
OS: Linux
unspecified
urgent
Target Milestone: rc
: ---
Assignee: David Knox
QA Contact: Michal Karm Babacek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-05-08 06:52 UTC by Sidney Markowitz
Modified: 2018-12-06 16:27 UTC (History)
5 users (show)

Fixed In Version: tomcat6-6.0.24-67.el6_5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-07-09 15:16:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2014:0865 0 normal SHIPPED_LIVE Moderate: tomcat6 security and bug fix update 2014-07-09 19:16:10 UTC

Description Sidney Markowitz 2014-05-08 06:52:25 UTC
Description of problem:

The patch file tomcat6-6.0.24-CVE-2013-4322.patch which is in tomcat6-6.0.24-64.el6_5.src.rpm has a typo in code copied from tomcat7 which crashes my web application which uses chunked transfer. The code in tomcat7 has a comparison testing for less than zero, and the patch file incorrectly tests for greater than 0. Details are below.

Version-Release number of selected component (if applicable):

  tomcat6-6.0.24-64.el6_5.src.rpm

How reproducible:

  My application always fails after installing this rpm, works after a yum downgrade, fails again if I upgrade again. If I disable chunked transfer in the client then it does not get the exception. I did not see the failure in a small test case that uses chunked transfer. However, the bug is obvious if you look at the compare the line of code I will describe in the patch file with the corresponding code in the original tomcat 7 source it is copied from.

  The effect of the typo is that when trying to look for extension or transfer headers at the end of chunked data, if an internal read buffer has been completely read and more data needs to be read in, and this happens at a particular path through the code, a check there for end of the stream throws the EOFException when there is more data available instead of when there is not more data available.

Steps to Reproduce:

  Inside tomcat6-6.0.24-64.el6_5.src.rpm look at file
tomcat6-6.0.24-CVE-2013-4322.patch
and locate the lines

-        return parseCRLF(); // FIXME
+    private boolean parseHeader() 
+        throws IOException {
+        
+        MimeHeaders headers = request.getMimeHeaders();
+        byte chr = 0;
 
+        // Read new bytes if needed
+        if (pos >= lastValid) {
+            if (readBytes() > 0)
+                throw new EOFException(
+                    "Unexpected end of stream while reading trailer headers for chunked request");
+        }
+

The method readBytes() indicates an EOF by returning a negative number, so the if test is backwards in the two lines

+        if (pos >= lastValid) {
+            if (readBytes() > 0)

Notice that following it in the same chunk of the patch file there are four more instances of this, except with the test being for less than 0 (as it should be)

+        if (pos >= lastValid) {
+            if (readBytes() < 0)


Now look at the original code by searching for

private boolean parseHeader()

in the tomcat 7 version of this source code on this page

http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java


Actual results:

The Apache Tomcat 7 version of the code says if (readBytes() < 0)
The patch file containing the backport says if (readBytes() > 0)

Expected results:

The backported patch should match the code it is being backported from.

Additional info:

I built rpms from tomcat6-6.0.24-64.el6_5.src.rpm and verified that installing those rpms demonstrated the same crash in my application, which went away when downgrading to tomcat6-6.0.24-62. I then changed the bad zero comparison in the patch file and built rpms from that. Installing those rpms did fix the crash in my application.

Comment 3 Jean-frederic Clere 2014-05-09 07:41:38 UTC
The patch is broken the correct code should be something like:
+++
    private boolean parseHeader() throws IOException {

        MimeHeaders headers = request.getMimeHeaders();

        byte chr = 0;

        // Read new bytes if needed
        if (pos >= lastValid) {
            if (readBytes() <0)
                throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request");
        }

+++

./rhel-6.6/tomcat6-6.0.24-CVE-2013-4322.patch (broken)

Comment 5 Michal Karm Babacek 2014-07-03 17:00:50 UTC
O.K.

Comment 7 errata-xmlrpc 2014-07-09 15:16:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2014-0865.html


Note You need to log in before you can comment on or make changes to this bug.