CVE-2022-39348: Twisted Twisted Vulnerable To NameVirtualHost Host Vulnerability
MODERATECVE-2022-39348 is a MODERATE (CVSS 5.4) twisted vulnerable to namevirtualhost host vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Twisted libraries in the PyPI ecosystem. The issue involves twisted vulnerable to namevirtualhost host header injection. Remediation is available by upgrading affected packages to version 22.10.0rc1.
CVE-2022-39348 at a Glance
Security Impact
CVSS: 5.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2022-39348
To remediate this vulnerability, upgrade all affected Twisted dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install Twisted>=22.10.0rc1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show Twisted
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2022-39348, inspect your installed packages using pip:
pip show Twisted
Analyze the terminal output to locate any version of Twisted in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 22.10.0rc1), your application is affected.
Note: The pip show Twisted command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Twisted, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-39348 Affected Twisted Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
Twisted
|
PyPI |
≥ 0.9.4
< 22.10.0rc1
|
22.10.0rc1
|
References
Frequently Asked Questions
What is CVE-2022-39348?
Which Twisted versions are affected?
What version fixes CVE-2022-39348?
Is Twisted affected?
What is the CVSS score of CVE-2022-39348?
What CWE is associated with CVE-2022-39348?
How can I check PyPI dependencies for CVE-2022-39348?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-vg46-2rrj-3647",
"modified" : "2025-11-04T16:39:47Z",
"published" : "2022-10-26T22:08:39Z",
"aliases" : [ "CVE-2022-39348" ],
"summary" : "Twisted vulnerable to NameVirtualHost Host header injection",
"details" : "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.\n\nExample configuration:\n```python\nfrom twisted.web.server import Site\nfrom twisted.web.vhost import NameVirtualHost\nfrom twisted.internet import reactor\n\nresource = NameVirtualHost()\nsite = Site(resource)\nreactor.listenTCP(8080, site)\nreactor.run()\n```\nOutput:\n```\n❯ curl -H\"Host:<h1>HELLO THERE</h1>\" http://localhost:8080/\n\n<html>\n <head><title>404 - No Such Resource</title></head>\n <body>\n <h1>No Such Resource</h1>\n <p>host b'<h1>hello there</h1>' not in vhost map</p>\n </body>\n</html>\n```\n\nThis vulnerability was introduced in f49041bb67792506d85aeda9cf6157e92f8048f4 and first appeared in the 0.9.4 release.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "Twisted"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.9.4"
}, {
"fixed" : "22.10.0rc1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/security/advisories/GHSA-vg46-2rrj-3647"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-39348"
}, {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/commit/f2f5e81c03f14e253e85fe457e646130780db40b"
}, {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/commit/f49041bb67792506d85aeda9cf6157e92f8048f4"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/twisted/twisted"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2022/11/msg00038.html"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2024/11/msg00028.html"
}, {
"type" : "WEB",
"url" : "https://security.gentoo.org/glsa/202301-02"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79", "CWE-80" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-10-26T22:08:39Z",
"nvd_published_at" : "2022-10-26T20:15:00Z"
}
}