Bug 1128396

Summary: NullPointerException in chunked transfer encoding input filter when processing last-chunk
Product: Red Hat Enterprise Linux 6 Reporter: stein
Component: tomcat6Assignee: David Knox <dknox>
Status: CLOSED ERRATA QA Contact: tomcat-qe
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.5CC: alexxed, csutherl, dknox, fgoldefu, jclere, pslavice, r.spek, tlavigne, tomcat-qe
Target Milestone: rc   
Target Release: ---   
Hardware: noarch   
OS: Linux   
Whiteboard:
Fixed In Version: tomcat6-6.0.24-87.el6 Doc Type: Bug Fix
Doc Text:
Requests using chunked transfer encoding generated a "NullPointerException" in the parseHeader() function of ChunkedInputFilter.java when the last chunk was processed. Consequently, HTTP connection was aborted by tomcat. The underlying code has been amended, and HTTP connection is no longer lost in this situation.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 07:27:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description stein 2014-08-10 02:30:22 UTC
Description of problem:
Requests using chunked transfer encoding will generate a NullPointerException in parseHeader() of ChunkedInputFilter.java when the zero-length last-chunk is processed.

Sample log entry from catalina.out:
Aug 01, 2014 12:34:56 AM org.apache.coyote.http11.Http11Processor process
SEVERE: Error finishing request
java.lang.NullPointerException
        at org.apache.coyote.http11.filters.ChunkedInputFilter.parseHeader(ChunkedInputFilter.java:420)
        at org.apache.coyote.http11.filters.ChunkedInputFilter.parseEndChunk(ChunkedInputFilter.java:409)
        at org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:155)
        at org.apache.coyote.http11.filters.ChunkedInputFilter.end(ChunkedInputFilter.java:208)
        at org.apache.coyote.http11.InternalInputBuffer.endRequest(InternalInputBuffer.java:336)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:886)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:745)


Patch file tomcat6-6.0.24-CVE-2013-4322.patch, which was introduced with 6.0.24.64, modified the doRead() function in ChunkedInputFilter.java by adding the following line at the start of doRead():

        this.request = req;

However, this line does not appear in the upstream tomcat6 source for ChunkedInputFilter.java.  Is it a typo?

By overwriting 'request' at this point in doRead(), the NullPointerException occurs when the following line at the start of parseHeader() is executed when processing the last chunk (other chunks are processed without error):

        MimeHeaders headers = request.getMimeHeaders();


The fix is to comment out (or remove) the "this.request = req;" line in the doRead() function in java/org/apache/coyote/http11/filters/ChunkedInputFilter.java



Version-Release number of selected component (if applicable):
tomcat6 6.0.24.64.el6
tomcat6 6.0.24.72.el6


How reproducible:
NullPointerException occurs every time


Steps to Reproduce:
1. Generate an HTTP request to tomcat using chunked Transfer Encoding, such as:

POST /application HTTP/1.1
Host: localhost:8080
Transfer-Encoding: chunked

2d
<html><body>TEST TEST TEST TEST</body></html>
0



Actual results:
java.lang.NullPointerException logged to catalina.out and HTTP connection is aborted by tomcat

Expected results:
No exceptions are logged and the HTTP connection is not aborted abnormally by tomcat

Comment 2 stein 2014-08-13 20:55:06 UTC
error still occurs with tomcat6 6.0.24.78.el6

Comment 8 errata-xmlrpc 2015-07-22 07:27:52 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.

https://rhn.redhat.com/errata/RHBA-2015-1461.html

Comment 9 Red Hat Bugzilla 2023-09-14 02:45:29 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days