View Issue Details

IDProjectCategoryView StatusLast Update
0003392libmicrohttpdHTTPS (TLS)public2021-09-02 17:54
Reportergmsoft Assigned ToChristian Grothoff  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.34 
Target Version0.9.37Fixed in Version0.9.37 
Summary0003392: Infinite loop when HTTPS connection is reset (Denial of Service)
DescriptionWhen a SSL connection is reset, socket errno is set to ECONNRESET in recv_tls_adapter(). Unfortunately, do_read() in connection.c treat this as non fatal (same a EINTR, EAGAIN and EWOULDBLOCK) and happily tries to read again and again from that connection.

When using multiple threads, each thread affected will use 100% CPU and no resource will be freed.
Steps To ReproduceEstablish an HTTPS connection and reset it before the reply.
Additional InformationThe attached fix solves the problem for me by simply closing the connection on ECONNRESET.

TagsNo tags attached.
Attached Files
libmicrohttp-ECONNRESET.diff (811 bytes)   
Fix infinite loop (DoS) when HTTP connection is reset.

Signed-off-by: Guy Martin <gmsoft@tuxicoman.be>

Index: src/microhttpd/connection.c
===================================================================
--- src/microhttpd/connection.c	(revision 33148)
+++ src/microhttpd/connection.c	(working copy)
@@ -1612,9 +1612,13 @@
   if (bytes_read < 0)
     {
       const int err = MHD_socket_errno_;
-      if ((EINTR == err) || (EAGAIN == err) || (ECONNRESET == err)
-          || (EWOULDBLOCK == err))
+      if ((EINTR == err) || (EAGAIN == err) || (EWOULDBLOCK == err))
 	  return MHD_NO;
+      if (ECONNRESET == err)
+        {
+           CONNECTION_CLOSE_ERROR(connection, NULL);
+	   return MHD_NO;
+	}
 #if HAVE_MESSAGES
 #if HTTPS_SUPPORT
       if (0 != (connection->daemon->options & MHD_USE_SSL))

Activities

Christian Grothoff

2014-05-02 20:24

manager   ~0008275

Fixed as suggested in SVN 33156.

Christian Grothoff

2021-09-02 17:54

manager   ~0018207

Fix committed to master branch.

Related Changesets

libmicrohttpd: master 312d11ec

2014-05-02 22:23

Christian Grothoff


Details Diff
fix 0003392 as suggested by reporter Affected Issues
0003392
mod - AUTHORS Diff File
mod - ChangeLog Diff File

Issue History

Date Modified Username Field Change
2014-04-30 14:02 gmsoft New Issue
2014-04-30 14:02 gmsoft File Added: libmicrohttp-ECONNRESET.diff
2014-05-02 20:24 Christian Grothoff Note Added: 0008275
2014-05-02 20:24 Christian Grothoff Status new => resolved
2014-05-02 20:24 Christian Grothoff Fixed in Version => 0.9.35
2014-05-02 20:24 Christian Grothoff Resolution open => fixed
2014-05-02 20:24 Christian Grothoff Assigned To => Christian Grothoff
2014-05-02 20:24 Christian Grothoff Target Version => 0.9.35
2014-05-02 20:52 Christian Grothoff Status resolved => closed
2014-06-02 00:12 Christian Grothoff Target Version 0.9.35 => 0.9.37
2014-06-02 00:15 Christian Grothoff Fixed in Version 0.9.35 => 0.9.37
2021-09-02 17:54 Christian Grothoff Changeset attached => libmicrohttpd master 312d11ec
2021-09-02 17:54 Christian Grothoff Note Added: 0018207
2024-01-21 13:25 Christian Grothoff Category HTTPS (SSL) => HTTPS (TLS)