# CVE-2021-27291: Pygments vulnerable to Regular Expression Denial of Service (ReDoS)

- Severity: High 7.5 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 3.91%, higher than 90% of CVEs (2026-12-01)
- Public exploit code or proof of concept: one link below, marked "exploit"
- Published: 2021-03-17T12:31:15.000Z
- Modified: 2026-06-17T03:44:37.283Z
- Also known as: GHSA-pq64-v7f5-gqh8, PYSEC-2021-141
- Weaknesses: CWE-400, CWE-1333
- Assigned by: mitre

## Description

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.

(As written by CVE List.)

## Affected

- Unspecified product: n/a
- pygments (PyPI): from 1.1 before 2.7.4; before 2e7e8c4a7b318f4032493773732754e418279a14
- pygments pygments: from 1.1 before 2.7.4
- debian debian_linux: 9.0; 10.0
- fedoraproject fedora: 32; 33

## Every score

- GitHub: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- GitHub: CVSS:4.0 High `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`
- NVD: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- NVD: CVSS:2.0 5.0 Medium `AV:N/AC:L/Au:N/C:N/I:N/A:P`

## References

- <https://gist.github.com/b-c-ds/b1a2cc0c68a35c57188575eb496de5ce> (exploit, third-party-advisory, web)
- <https://github.com/pygments/pygments/commit/2e7e8c4a7b318f4032493773732754e418279a14> (fix, patch, third-party-advisory, web)
- <https://lists.debian.org/debian-lts-announce/2021/03/msg00024.html> (mailing-list, third-party-advisory, web)
- <https://www.debian.org/security/2021/dsa-4878> (advisory, third-party-advisory, vendor-advisory, web)
- <https://www.debian.org/security/2021/dsa-4889> (advisory, third-party-advisory, vendor-advisory, web)
- <https://lists.debian.org/debian-lts-announce/2021/05/msg00003.html> (mailing-list, third-party-advisory, web)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55/> (vendor-advisory)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ/> (vendor-advisory)
- <https://lists.debian.org/debian-lts-announce/2021/05/msg00006.html> (mailing-list, third-party-advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-27291> (advisory)
- <https://github.com/pygments/pygments> (package)
- <https://github.com/pypa/advisory-database/tree/main/vulns/pygments/PYSEC-2021-141.yaml> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ/> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55/> (web)
- <https://github.com/advisories/GHSA-pq64-v7f5-gqh8> (advisory)

## Sources

- CVE List: [CVE-2021-27291](https://www.cve.org/CVERecord?id=CVE-2021-27291), CVE Terms of Use, modified 2024-08-03
- GitHub Advisory Database: [GHSA-pq64-v7f5-gqh8](https://github.com/advisories/GHSA-pq64-v7f5-gqh8), CC-BY-4.0, modified 2024-10-14
- NVD: [CVE-2021-27291](https://nvd.nist.gov/vuln/detail/CVE-2021-27291), Public domain, modified 2026-06-17
- PyPA Advisory Database: [PYSEC-2021-141](https://osv.dev/vulnerability/PYSEC-2021-141), CC-BY-4.0, modified 2023-11-08

---

Page: https://cve.day/CVE-2021-27291 · Whole record: https://cve.day/CVE-2021-27291.json · Rebuilt by cve.day 2026-11-25T22:58:00.310Z
