Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix CVE-2011-3190
Prevent AJP request forgery via unread request body packet

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk@1162958 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Aug 29, 2011
1 parent e0796d7 commit 90ec967
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
5 changes: 5 additions & 0 deletions java/org/apache/coyote/ajp/AbstractAjpProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,11 @@ protected void finish() throws IOException {

finished = true;

// Swallow the unread body packet if present
if (first && request.getContentLengthLong() > 0) {
receive();
}

// Add the end message
if (error) {
output(endAndCloseMessageArray, 0, endAndCloseMessageArray.length);
Expand Down
10 changes: 6 additions & 4 deletions java/org/apache/coyote/ajp/AjpAprProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ public SocketState process(SocketWrapper<Long> socket)
}
continue;
} else if(type != Constants.JK_AJP13_FORWARD_REQUEST) {
// Usually the servlet didn't read the previous request body
if(log.isDebugEnabled()) {
log.debug("Unexpected message: "+type);
// Unexpected packet type. Unread body packets should have
// been swallowed in finish().
if (log.isDebugEnabled()) {
log.debug("Unexpected message: " + type);
}
continue;
error = true;
break;
}

keptAlive = true;
Expand Down
10 changes: 6 additions & 4 deletions java/org/apache/coyote/ajp/AjpNioProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ public SocketState process(SocketWrapper<NioChannel> socket)
recycle(false);
continue;
} else if(type != Constants.JK_AJP13_FORWARD_REQUEST) {
// Usually the servlet didn't read the previous request body
if(log.isDebugEnabled()) {
log.debug("Unexpected message: "+type);
// Unexpected packet type. Unread body packets should have
// been swallowed in finish().
if (log.isDebugEnabled()) {
log.debug("Unexpected message: " + type);
}
error = true;
recycle(true);
continue;
break;
}
request.setStartTime(System.currentTimeMillis());
} catch (IOException e) {
Expand Down
11 changes: 6 additions & 5 deletions java/org/apache/coyote/ajp/AjpProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ public SocketState process(SocketWrapper<Socket> socket)
}
continue;
} else if(type != Constants.JK_AJP13_FORWARD_REQUEST) {
// Usually the servlet didn't read the previous request body
if(log.isDebugEnabled()) {
log.debug("Unexpected message: "+type);
// Unexpected packet type. Unread body packets should have
// been swallowed in finish().
if (log.isDebugEnabled()) {
log.debug("Unexpected message: " + type);
}
continue;
error = true;
break;
}

request.setStartTime(System.currentTimeMillis());
} catch (IOException e) {
error = true;
Expand Down
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
Detect incomplete AJP messages and reject the associated request if one
is found. (markt)
</add>
<fix>
<bug>51698</bug>: Fix CVE-2011-3190. Prevent AJP message injection.
(markt)
</fix>
</changelog>
</subsection>
<subsection name="Jasper">
Expand Down

0 comments on commit 90ec967

Please sign in to comment.