You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/06/15 10:09:41 UTC

[tomcat] branch main updated: Reduce overhead count by 2 rather than 1 for non-overhead frames

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 2698cfb  Reduce overhead count by 2 rather than 1 for non-overhead frames
2698cfb is described below

commit 2698cfb178b81513276e2093bf2a19e04cca1b90
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jun 14 22:12:46 2021 +0100

    Reduce overhead count by 2 rather than 1 for non-overhead frames
    
    This means that the overhead count for a well-behaved conenction should
    trend downwards over time.
---
 java/org/apache/coyote/http2/Http2Protocol.java | 2 +-
 webapps/docs/changelog.xml                      | 7 +++++++
 webapps/docs/config/http2.xml                   | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2Protocol.java b/java/org/apache/coyote/http2/Http2Protocol.java
index 230f8f0..e3028f8 100644
--- a/java/org/apache/coyote/http2/Http2Protocol.java
+++ b/java/org/apache/coyote/http2/Http2Protocol.java
@@ -58,7 +58,7 @@ public class Http2Protocol implements UpgradeProtocol {
     static final int DEFAULT_OVERHEAD_COUNT_FACTOR = 1;
     // Not currently configurable. This makes the practical limit for
     // overheadCountFactor to be 2.
-    static final int DEFAULT_OVERHEAD_REDUCTION_FACTOR = -1;
+    static final int DEFAULT_OVERHEAD_REDUCTION_FACTOR = -2;
     static final int DEFAULT_OVERHEAD_CONTINUATION_THRESHOLD = 1024;
     static final int DEFAULT_OVERHEAD_DATA_THRESHOLD = 1024;
     static final int DEFAULT_OVERHEAD_WINDOW_UPDATE_THRESHOLD = 1024;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index bbe0564..f98333f 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -127,6 +127,13 @@
         overhead count that Tomcat uses to detect and close potentially
         malicious connections. (markt)
       </add>
+      <update>
+        Many HTTP/2 requests from browsers will trigger one overhead frame and
+        one non-overhead frame. Change the overhead calculation so that a
+        non-overhead frame reduces the current overhead count by 2 rather than
+        1. This means that, over time, the overhead count for a well-behaved
+        connection will trend downwards. (markt)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Other">
diff --git a/webapps/docs/config/http2.xml b/webapps/docs/config/http2.xml
index f1b4538..9e5a148 100644
--- a/webapps/docs/config/http2.xml
+++ b/webapps/docs/config/http2.xml
@@ -136,7 +136,7 @@
     <attribute name="overheadCountFactor" required="false">
       <p>The factor to apply when counting overhead frames to determine if a
       connection has too high an overhead and should be closed. The overhead
-      count starts at <code>-10</code>. The count is decreased for each
+      count starts at <code>-10</code>. The count is decreased by 2 for each
       data frame sent or received and each headers frame received. The count is
       increased by the <code>overheadCountFactor</code>for each setting
       received, priority frame received and ping received. If the overhead count

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch main updated: Reduce overhead count by 2 rather than 1 for non-overhead frames

Posted by Mark Thomas <ma...@apache.org>.
On 15/06/2021 11:09, markt@apache.org wrote:
> This is an automated email from the ASF dual-hosted git repository.
> 
> markt pushed a commit to branch main
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> 
> 
> The following commit(s) were added to refs/heads/main by this push:
>       new 2698cfb  Reduce overhead count by 2 rather than 1 for non-overhead frames
> 2698cfb is described below
> 
> commit 2698cfb178b81513276e2093bf2a19e04cca1b90
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Mon Jun 14 22:12:46 2021 +0100
> 
>      Reduce overhead count by 2 rather than 1 for non-overhead frames
>      
>      This means that the overhead count for a well-behaved conenction should
>      trend downwards over time.

This changes the behaviour for the HTTP/2 overhead protection but I 
intend to back-port this all the way to 8.5.x.

My reasoning is:

- the over head protection prior to recent changes was very likely to
   trigger false positives - this change makes that less likely

- the change makes it much more likely that a typical HTTP/2 connection
   will have an overhead count that trends down over time. This means a
   connection that is mostly well-behaved will not get closed as a result
   of one small instance of inefficient behaviour

- Tomcat was never susceptible to these DoS attacks so the overhead
   protection is more to close down abusive clients early and save
   server resources rather than to prevent a DoS. Therefore, making false
   positives less likely at the slight risk of increasing false negatives
   is acceptable.

- In the highly unlikely event that this is an issue for a user, the
   overheadCountFactor can be used (set it to double what it is now) to
   effectively undo this change


I've thought quite a bit about this over the last day or so while I have 
been working on it and while I'd normally be more adverse to 
back-porting this sort of change my current view is that this will be at 
worst neutral for users and will be an improvement for a significant 
majority of users who have enabled HTTP/2.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org