Skip to content

twisted.web has disordered HTTP pipeline response

Moderate severity GitHub Reviewed Published Oct 24, 2023 in twisted/twisted • Updated Nov 3, 2023

Package

pip twisted (pip)

Affected versions

< 23.10.0rc1

Patched versions

23.10.0rc1

Description

Twisted is an event-based framework for internet applications. Prior to version 23.10.0rc1, when sending multiple HTTP requests in one TCP packet, twisted.web will process the requests asynchronously without guaranteeing the response order. If one of the endpoints is controlled by an attacker, the attacker can delay the response on purpose to manipulate the response of the second request when a victim launched two requests using HTTP pipeline. Version 23.10.0rc1 contains a patch for this issue.

Details

There's an example faulty program:

from twisted.internet import reactor, endpoints
from twisted.web import server
from twisted.web.proxy import ReverseProxyResource
from twisted.web.resource import Resource

class Second(Resource):
    isLeaf = True
    def render_GET(self, request):
        return b'SECOND\n'

class First(Resource):
    isLeaf = True
    def render_GET(self, request):
        def send_response():
            request.write(b'FIRST DELAYED\n')
            request.finish()
        reactor.callLater(0.5, send_response)
        return server.NOT_DONE_YET

root = Resource()

root.putChild(b'second', Second())
root.putChild(b'first', First())

endpoint = endpoints.TCP4ServerEndpoint(reactor, 8080)
endpoint.listen(server.Site(root))
reactor.run()

When two requests for /first and /second are sent in the same order, the second request will be responded to first.

echo -en "GET /first HTTP/1.1\r\nHost: a\r\n\r\nGET /second HTTP/1.1\r\nHost: a\r\n\r\n" | nc localhost 8080

References

@adiroiban adiroiban published to twisted/twisted Oct 24, 2023
Published by the National Vulnerability Database Oct 25, 2023
Published to the GitHub Advisory Database Oct 25, 2023
Reviewed Oct 25, 2023
Last updated Nov 3, 2023

Severity

Moderate
5.3
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N

Weaknesses

CVE ID

CVE-2023-46137

GHSA ID

GHSA-xc8x-vp79-p3wm

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.