CVE-2022-39348: Twisted vulnerable to NameVirtualHost Host header injection
Twisted is an event-based framework for internet applications. Started with version 0.9.4, when the host header does not match a configured host twisted.web.vhost.NameVirtualHost will return a NoResource resource which renders the Host header unescaped into the 404 response allowing HTML and script injection. In practice this should be very difficult to exploit as being able to modify the Host header of a normal HTTP request implies that one is already in a privileged position. This issue was fixed in version 22.10.0rc1. There are no known workarounds.
Other sources
When the host header does not match a configured host, twisted.web.vhost.NameVirtualHost will return a NoResource resource which renders the Host header unescaped into the 404 response allowing HTML and script injection.
Example configuration: python from twisted.web.server import Site from twisted.web.vhost import NameVirtualHost from twisted.internet import reactor
resource = NameVirtualHost() site = Site(resource) reactor.listenTCP(8080, site) reactor.run() Output: ❯ curl -H"Host:<h1>HELLO THERE</h1>" http://localhost:8080/
<html> <head><title>404 - No Such Resource</title></head> <body> <h1>No Such Resource</h1> <p>host b'<h1>hello there</h1>' not in vhost map</p> </body> </html>
This vulnerability was introduced in f49041bb67792506d85aeda9cf6157e92f8048f4 and first appeared in the 0.9.4 release.
— GitHub
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the vulnerability ID of this security issue?
The vulnerability ID is CVE-2022-39348.
What is the severity of CVE-2022-39348?
The severity of CVE-2022-39348 is medium with a CVSS score of 5.4.
Which software versions are affected by CVE-2022-39348?
Versions of Twisted from 0.9.4 to 22.10.0 and Debian Linux 10.0 are affected by CVE-2022-39348.
How does CVE-2022-39348 impact the application?
CVE-2022-39348 allows the host header to be rendered unescaped into the 404 response, potentially exposing HTML and script injection vulnerabilities.
How can I fix the vulnerability CVE-2022-39348?
To fix CVE-2022-39348, make sure to update Twisted to version 22.10.0 or later, or apply the necessary security patches provided by the vendor.