CVE-2022-40896: Pygments Denial of Service Vulnerability
MODERATECVE-2022-40896 is a MODERATE (CVSS 5.5) denial of service vulnerability (CWE-434: Unrestricted Upload of File with Dangerous Type) affecting Pygments libraries in the PyPI ecosystem. The issue involves pygments vulnerable to redos. Remediation is available by upgrading affected packages to version 2.15.0.
CVE-2022-40896 at a Glance
Security Impact
CVSS: 5.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H).
How to Fix CVE-2022-40896
To remediate this vulnerability, upgrade all affected Pygments 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 Pygments>=2.15.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show Pygments
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2022-40896, inspect your installed packages using pip:
pip show Pygments
Analyze the terminal output to locate any version of Pygments in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.15.0), your application is affected.
Note: The pip show Pygments command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-434: Unrestricted Upload of File with Dangerous Type, where the product allows the upload or transfer of dangerous file types that are automatically processed within its environment. In Pygments, 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-40896 Affected Pygments Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
Pygments
|
PyPI |
< 2.15.0
|
2.15.0
|
References
Frequently Asked Questions
What is CVE-2022-40896?
Which Pygments versions are affected?
What version fixes CVE-2022-40896?
Is Pygments affected?
What is the CVSS score of CVE-2022-40896?
What CWE is associated with CVE-2022-40896?
How can I check PyPI dependencies for CVE-2022-40896?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-mrwq-x4v8-fh7p",
"modified" : "2024-10-24T21:49:45Z",
"published" : "2023-07-19T15:30:26Z",
"aliases" : [ "CVE-2022-40896" ],
"summary" : "Pygments vulnerable to ReDoS",
"details" : "A ReDoS issue was discovered in `pygments/lexers/smithy.py` in Pygments until 2.15.0 via SmithyLexer.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "Pygments"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.15.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-40896"
}, {
"type" : "WEB",
"url" : "https://github.com/pygments/pygments/commit/97eb3d5ec7c1b3ea4fcf9dee30a2309cf92bd194"
}, {
"type" : "WEB",
"url" : "https://github.com/pygments/pygments/commit/dd52102c38ebe78cd57748e09f38929fd283ad04"
}, {
"type" : "WEB",
"url" : "https://github.com/pygments/pygments/commit/fdf182a7af85b1deeeb637ca970d31935e7c9d52"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/pygments/pygments"
}, {
"type" : "WEB",
"url" : "https://github.com/pygments/pygments/blob/master/pygments/lexers/smithy.py#L61"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pygments/PYSEC-2023-117.yaml"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/EZGMXALE3HSP4OXC7UUWIKX3OXKZDTY3"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/VUZO4BQCIY2S2KZYHERQMKURB7AHXDBO"
}, {
"type" : "WEB",
"url" : "https://pypi.org/project/Pygments"
}, {
"type" : "WEB",
"url" : "https://pyup.io/posts/pyup-discovers-redos-vulnerabilities-in-top-python-packages-part-2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-434" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2023-07-20T11:00:04Z",
"nvd_published_at" : "2023-07-19T15:15:10Z"
}
}