CVE-2022-21716: Twisted Twisted SSH Client And Server Vulnerability
HIGHCVE-2022-21716 is a HIGH (CVSS 7.5) twisted ssh client and server vulnerability (CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')) affecting Twisted libraries in the PyPI ecosystem. The issue involves twisted ssh client and server deny of service during ssh handshake.. Remediation is available by upgrading affected packages to version 22.2.0.
CVE-2022-21716 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2022-21716
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.2.0
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-21716, 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.2.0), 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-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow'), where the product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer. 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-21716 Affected Twisted Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
twisted
|
PyPI |
≥ 21.7.0
< 22.2.0
|
22.2.0
|
References
Frequently Asked Questions
What is CVE-2022-21716?
Which Twisted versions are affected?
What version fixes CVE-2022-21716?
Is twisted affected?
What is the CVSS score of CVE-2022-21716?
What CWE is associated with CVE-2022-21716?
How can I check PyPI dependencies for CVE-2022-21716?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rv6r-3f5q-9rgx",
"modified" : "2024-11-25T18:33:22Z",
"published" : "2022-03-03T19:02:08Z",
"aliases" : [ "CVE-2022-21716" ],
"summary" : "Twisted SSH client and server deny of service during SSH handshake.",
"details" : "### Impact\n\nThe Twisted SSH client and server implementation naively accepted an infinite amount of data for the peer's SSH version identifier.\n\nA malicious peer can trivially craft a request that uses all available memory and crash the server, resulting in denial of service. The attack is as simple as `nc -rv localhost 22 < /dev/zero`.\n\n### Patches\n\nThe issue was fix in GitHub commit https://github.com/twisted/twisted/commit/98387b39e9f0b21462f6abc7a1325dc370fcdeb1\n\nA fix is available in Twisted 22.2.0.\n\n### Workarounds\n\n* Limit access to the SSH server only to trusted source IP addresses.\n* Connect over SSH only to trusted destination IP addresses.\n\n### References\n\nReported at https://twistedmatrix.com/trac/ticket/10284\nDiscussions at https://github.com/twisted/twisted/security/advisories/GHSA-rv6r-3f5q-9rgx\n\n### For more information\n\nFound by vin01",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "twisted"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "21.7.0"
}, {
"fixed" : "22.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/security/advisories/GHSA-rv6r-3f5q-9rgx"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21716"
}, {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/commit/89c395ee794e85a9657b112c4351417850330ef9"
}, {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/commit/98387b39e9f0b21462f6abc7a1325dc370fcdeb1"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/twisted/PYSEC-2022-160.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/twisted/twisted"
}, {
"type" : "WEB",
"url" : "https://github.com/twisted/twisted/releases/tag/twisted-22.2.0"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2022/03/msg00009.html"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/7U6KYDTOLPICAVSR34G2WRYLFBD2YW5K"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GLKHA6WREIVAMBQD7KKWYHPHGGNKMAG6"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/7U6KYDTOLPICAVSR34G2WRYLFBD2YW5K"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GLKHA6WREIVAMBQD7KKWYHPHGGNKMAG6"
}, {
"type" : "WEB",
"url" : "https://security.gentoo.org/glsa/202301-02"
}, {
"type" : "WEB",
"url" : "https://twistedmatrix.com/trac/ticket/10284"
}, {
"type" : "WEB",
"url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-120", "CWE-770" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-03-03T19:02:08Z",
"nvd_published_at" : "2022-03-03T21:15:00Z"
}
}