PyPI: pygments
CVE-2022-40896
Safety vulnerability ID: SFTY-20230719-20134
Safety legacy ID: pyup.io-58910
Pygments 2.15.0 includes a fix for CVE-2022-40896: The regular expressions used when parsing Smithy, SQL/SQL+Jinja, and Java properties files were discovered to be vulnerable. As a result, pygmentizing a maliciously-crafted file of these kinds would have resulted in high resources consumption or crashing of the application. https://pyup.io/posts/pyup-discovers-redos-vulnerabilities-in-top-python-packages-part-2
Overview
Pygments vulnerable to ReDoS
Advisory
Pygments 2.15.0 includes a fix for CVE-2022-40896: The regular expressions used when parsing Smithy, SQL/SQL+Jinja, and Java properties files were discovered to be vulnerable. As a result, pygmentizing a maliciously-crafted file of these kinds would have resulted in high resources consumption or crashing of the application. https://pyup.io/posts/pyup-discovers-redos-vulnerabilities-in-top-python-packages-part-2
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20230719-20134/CVE-2022-40896
- https://nvd.nist.gov/vuln/detail/CVE-2022-40896
- https://github.com/pygments/pygments/blob/master/pygments/lexers/smithy.py#L61
- https://github.com/pygments/pygments/commit/97eb3d5ec7c1b3ea4fcf9dee30a2309cf92bd194
- https://github.com/pygments/pygments/commit/dd52102c38ebe78cd57748e09f38929fd283ad04
- https://github.com/pygments/pygments/commit/fdf182a7af85b1deeeb637ca970d31935e7c9d52
- https://github.com/pypa/advisory-database/tree/main/vulns/pygments/PYSEC-2023-117.yaml
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/EZGMXALE3HSP4OXC7UUWIKX3OXKZDTY3
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/VUZO4BQCIY2S2KZYHERQMKURB7AHXDBO
- https://pypi.org/project/Pygments
- https://pyup.io/posts/pyup-discovers-redos-vulnerabilities-in-top-python-packages-part-2
- https://github.com/advisories/GHSA-mrwq-x4v8-fh7p
Verified by Safety
Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.
Learn more
