View Issue Details

IDProjectCategoryView StatusLast Update
0003392libmicrohttpdHTTPS (TLS)public2021-09-02 15:54
Reportergmsoft Assigned ToChristian Grothoff Due Date
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 18:24

manager   ~0008275

Fixed as suggested in SVN 33156.

Christian Grothoff

2021-09-02 15:54

manager   ~0018207

Fix committed to master branch.

Issue History

Date ModifiedUsernameFieldChange
2014-04-30 12:02gmsoftNew Issue
2014-04-30 12:02gmsoftFile Added: libmicrohttp-ECONNRESET.diff
2014-05-02 18:24Christian GrothoffNote Added: 0008275
2014-05-02 18:24Christian GrothoffStatusnew => resolved
2014-05-02 18:24Christian GrothoffFixed in Version => 0.9.35
2014-05-02 18:24Christian GrothoffResolutionopen => fixed
2014-05-02 18:24Christian GrothoffAssigned To => Christian Grothoff
2014-05-02 18:24Christian GrothoffTarget Version => 0.9.35
2014-05-02 18:52Christian GrothoffStatusresolved => closed
2014-06-01 22:12Christian GrothoffTarget Version0.9.35 => 0.9.37
2014-06-01 22:15Christian GrothoffFixed in Version0.9.35 => 0.9.37
2021-09-02 15:54Christian Grothoff
2021-09-02 15:54Christian GrothoffNote Added: 0018207
2024-01-21 12:25Christian GrothoffCategoryHTTPS (SSL) => HTTPS (TLS)