First published: Mon Feb 13 2012(Updated: )
Description of problem: When using SimpleXMLRPCServer from the standard library, if a client connection is closed before the complete request body has been received the server will enter an infinite loop consuming memory. Version-Release number of selected component (if applicable): python-2.6.6-29.el6.x86_64 How reproducible: always Steps to Reproduce: 1. Start the server: <span class="quote">>>> import SimpleXMLRPCServer, SocketServer >>> class Server(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer): pass</span> ... <span class="quote">>>> Server(('0.0.0.0', 12345)).serve_forever()</span> 2. Simulate a malicious or flakey client: $ echo -e 'POST /RPC2 HTTP/1.0\r\nContent-Length: 100\r\n\r\nlol bye' | nc localhost 12345 ^C Actual results: Server goes nuts, with a thread stuck in an infinite loop eating memory. Expected results: Bad request is discarded. Additional info: The bug is in /usr/lib64/python2.6/SimpleXMLRPCServer.py at line 453: # Get arguments by reading body of request. # We read this in chunks to avoid straining # socket.read(); around the 10 or 15Mb mark, some platforms # begin to have problems (bug #792570). max_chunk_size = 10*1024*1024 size_remaining = int(self.headers["content-length"]) L = [] while size_remaining: chunk_size = min(size_remaining, max_chunk_size) L.append(self.rfile.read(chunk_size)) size_remaining -= len(L[-1]) data = ''.join(L) This code does not correctly handle EOF from self.rfile.read().
Credit: secalert@redhat.com secalert@redhat.com
Affected Software | Affected Version | How to fix |
---|---|---|
Python Python | <=2.6.7 | |
Python Python | =0.9.0 | |
Python Python | =0.9.1 | |
Python Python | =1.2 | |
Python Python | =1.3 | |
Python Python | =1.5.2 | |
Python Python | =1.6 | |
Python Python | =1.6.1 | |
Python Python | =2.0 | |
Python Python | =2.0.1 | |
Python Python | =2.1 | |
Python Python | =2.1.1 | |
Python Python | =2.1.2 | |
Python Python | =2.1.3 | |
Python Python | =2.2 | |
Python Python | =2.2.1 | |
Python Python | =2.2.2 | |
Python Python | =2.2.3 | |
Python Python | =2.3.1 | |
Python Python | =2.3.2 | |
Python Python | =2.3.3 | |
Python Python | =2.3.4 | |
Python Python | =2.3.5 | |
Python Python | =2.3.7 | |
Python Python | =2.4.1 | |
Python Python | =2.4.2 | |
Python Python | =2.4.3 | |
Python Python | =2.4.4 | |
Python Python | =2.4.6 | |
Python Python | =2.5.1 | |
Python Python | =2.5.2 | |
Python Python | =2.5.3 | |
Python Python | =2.5.4 | |
Python Python | =2.5.6 | |
Python Python | =2.5.150 | |
Python Python | =2.6.1 | |
Python Python | =2.6.2 | |
Python Python | =2.6.3 | |
Python Python | =2.6.4 | |
Python Python | =2.6.5 | |
Python Python | =2.6.6 | |
Python Python | =2.6.2150 | |
Python Python | =2.6.6150 | |
Python Python | =2.7.1 | |
Python Python | =2.7.1-rc1 | |
Python Python | =2.7.2-rc1 | |
Python Python | =2.7.1150 | |
Python Python | =2.7.2150 | |
Python Python | =3.0 | |
Python Python | =3.0.1 | |
Python Python | =3.1 | |
Python Python | =3.1.1 | |
Python Python | =3.1.2 | |
Python Python | =3.1.3 | |
Python Python | =3.1.4 | |
Python Python | =3.2 | |
Python Python | =3.2-alpha | |
Python Python | =3.2.2150 | |
redhat/python | <2.6.8 | 2.6.8 |
redhat/python | <2.7.3 | 2.7.3 |
redhat/python | <3.1.5 | 3.1.5 |
redhat/python | <3.2.3 | 3.2.3 |
debian/python2.7 | 2.7.18-8+deb11u1 |
Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.