[#4595] New block syntax — Daniel Amelang <daniel.amelang@...>

I'm really sorry if this isn't the place to talk about this. I've

25 messages 2005/03/21
[#4606] Re: New block syntax — "David A. Black" <dblack@...> 2005/03/21

Hi --

[#4629] Re: New block syntax — "Sean E. Russell" <ser@...> 2005/03/30

On Monday 21 March 2005 16:17, David A. Black wrote:

[#4648] about REXML::Encoding — speakillof <speakillof@...>

Hi.

15 messages 2005/03/31
[#4659] Re: about REXML::Encoding — "Sean E. Russell" <ser@...> 2005/04/04

On Thursday 31 March 2005 09:44, speakillof wrote:

Patch for denial of service vulnerability in WEBrick

From: Dominique Brezinski <dom@...>
Date: 2005-03-05 04:29:45 UTC
List: ruby-core #4518
We built a service using WEBrick with SSL enabled, and in the process
of testing found a denial of service vulnerability in WEBrick. If
connections are terminated during the SSL handsake, an exception is
raised that is not properly handled in webrick/server.rb. The result
is that there is a leak in the token queue used to limit the number of
threads created to handle connections. When the queue leaked to empty,
the server sits in the IO::select loop trying to pop a token from the
queue, but won't block because there is only the single thread
running. The server becomes unavailable, and it creates a nice big log 
file too (500MB in a minute or two)
;>

Here is a patch for 1.8.2 that fixes this and a related leak:

*** server.rb.old       Sat Mar  5 03:46:33 2005
--- server.rb   Sat Mar  5 03:52:12 2005
***************
*** 99,110 ****
--- 99,116 ----
            rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO 
=> ex
              # TCP connection was established but RST segment was sent
              # from peer before calling TCPServer#accept.
+             # This could cause a leak in the token queue since a token
+             # was popped between the select and accept, so we push one
+             @tokens.push(nil)
            rescue Errno::EBADF, IOError => ex
              # if the listening socket was closed in 
GenericServer#shutdown,
              # IO::select raise it.
            rescue Exception => ex
+             # if using SSL, a failed accept will raise an exception 
that is
+             # caught here, so we need to push a token to avoid a leak
              msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
              @logger.error msg
+             @tokens.push(nil)
            end
          end

***************
*** 168,175 ****
              @logger.debug "close: <address unknown>"
            end
            sock.close
          end
-         @tokens.push(nil)
        }
      end

--- 174,182 ----
              @logger.debug "close: <address unknown>"
            end
            sock.close
+           # move push inside ensure clause
+           @tokens.push(nil)
          end
        }
      end

In This Thread

Prev Next