Pygments vulnerable to Regular Expression Denial of Service (ReDoS)
Published 29 Mar 2021 · Updated 14 Oct 2024
Is your project on an affected pygments?
Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- >=1.1 <2.7.4
- Fixed in
- 2.7.4
pip install 'pygments>=2.7.4'Details
In pygments 1.1+, fixed in 2.7.4, the lexers used to parse programming languages rely heavily on regular expressions. Some of the regular expressions have exponential or cubic worst-case complexity and are vulnerable to ReDoS. By crafting malicious input, an attacker can cause a denial of service.
Is GHSA-pq64-v7f5-gqh8 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected pygments, and gives you the command that fixes it.
More advisories for pygments
- LowCVE-2026-4539Pygments has Regular Expression Denial of Service (ReDoS) due to Inefficient Regex for GUID Matching · 22 Mar 2026
- MediumCVE-2022-40896Pygments vulnerable to ReDoS · 19 Jul 2023
- CriticalCVE-2015-8557Command Injection in Pygments · 17 May 2022
- HighCVE-2021-20270Infinite Loop in Pygments · 20 Apr 2021
References
- Advisorynvd.nist.gov/vuln/detail/CVE-2021-27291
- Linkgithub.com/pygments/pygments/commit/2e7e8c4a7b318f4032493773732754e418279a14
- Linkgist.github.com/b-c-ds/b1a2cc0c68a35c57188575eb496de5ce
- Packagegithub.com/pygments/pygments
- Linkgithub.com/pypa/advisory-database/tree/main/vulns/pygments/PYSEC-2021-141.yaml
- Linklists.debian.org/debian-lts-announce/2021/03/msg00024.html
- Linklists.debian.org/debian-lts-announce/2021/05/msg00003.html
- Linklists.debian.org/debian-lts-announce/2021/05/msg00006.html
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ
- Linkwww.debian.org/security/2021/dsa-4878
- Linkwww.debian.org/security/2021/dsa-4889
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.