CVE-2022-39348: Twisted Twisted Vulnerable To NameVirtualHost Host Vulnerability

MODERATE
Advisory Identifier: GHSA-vg46-2rrj-3647
CVSS 5.4
CWE-80 CWE-79
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2022-39348
GHSA Identifier GHSA-vg46-2rrj-3647
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Twisted
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (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.

Twisted fixed: 22.10.0rc1
pip install Twisted>=22.10.0rc1
Verify Direct and Transitive Dependencies

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

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.

CVE-2022-39348 Affected Twisted Versions

1 component(s)
Fixed Versions:
22.10.0rc1
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?
CVE-2022-39348 is a security vulnerability in Twisted involving Twisted vulnerable to NameVirtualHost Host header injection under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Twisted versions are affected?
Affected versions include releases prior to 22.10.0rc1 across affected packages: Twisted.
What version fixes CVE-2022-39348?
Upgrading to 22.10.0rc1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Twisted affected?
Yes, Twisted is affected in releases prior to 22.10.0rc1. Upgrade your dependency to 22.10.0rc1 or later.
What is the CVSS score of CVE-2022-39348?
CVE-2022-39348 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2022-39348?
CVE-2022-39348 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (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.).
How can I check PyPI dependencies for CVE-2022-39348?
Run the dependency tree command: 'pip show Twisted'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}