{"id":797,"cve":"CVE-2022-21716","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2022-21716","cwe":"CWE-770","cwe_number":770,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/770","cvss_score":7.5,"published":"2022-03-03","owasp":"A06 Vulnerable and Outdated Components","odc":"Function","cdc":"Incorrect Functionality","category":"Resource Management","subcategory":"Resource Exhaustion","scope":"Remote","impact":"Denial of Service (DoS)","summary":"Twisted SSH version identifier DoS","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2022-21716\/","description":"Twisted is an event-based framework for internet applications, supporting Python 3.6+. Prior to 22.2.0, Twisted SSH client and server implement is able to accept an infinite amount of data for the peer's SSH version identifier. This ends up with a buffer using all the available memory. The attach is a simple as `nc -rv localhost 22 < \/dev\/zero`. A patch is available in version 22.2.0. There are currently no known workarounds.","solution":"Update to Twisted version 22.2.0 or higher.","affected_component":"Twisted","fixed_by_upgrading":true,"vulnerable_code":"from twisted.conch.ssh import transport\nfrom twisted.internet import reactor\n\nclass Transport(transport.SSHTransport):\n    def connectionSecure(self):\n        super().connectionSecure()\n\ndef create_server():\n    from twisted.internet import protocol\n    from twisted.conch.ssh import factory\n\n    class SSHFactory(factory.SSHFactory):\n        def buildProtocol(self, addr):\n            return Transport()\n\n    reactor.listenTCP(22, SSHFactory())\n    reactor.run()\n\ncreate_server()","patched_code":"from twisted.conch.ssh import transport\nfrom twisted.internet import reactor\n\nclass Transport(transport.SSHTransport):\n    MAX_VERSION_LENGTH = 255\n\n    def connectionSecure(self):\n        if len(self.peerVersion) > self.MAX_VERSION_LENGTH:\n            raise ValueError(\"SSH version identifier too long\")\n        super().connectionSecure()\n\ndef create_server():\n    from twisted.internet import protocol\n    from twisted.conch.ssh import factory\n\n    class SSHFactory(factory.SSHFactory):\n        def buildProtocol(self, addr):\n            return Transport()\n\n    reactor.listenTCP(22, SSHFactory())\n    reactor.run()\n\ncreate_server()","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[{"repository":"twisted\/twisted","commit_url":"https:\/\/github.com\/twisted\/twisted\/commit\/de90dfe1519e996dd150de751c670f8e03daa089","commit_subject":"Initial fix for Twisted version string DoS.","units":[{"file":"src\/twisted\/conch\/ssh\/transport.py","function":"SSHTransportBase.dataReceived"}]}],"references":null}