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/trunk@1162957 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Aug 29, 2011
1 parent 3513acc commit a2538ce
Show file tree
Hide file tree
Showing 4 changed files with 23 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

0 comments on commit a2538ce

Please sign in to comment.