# CVE-2021-20270: Infinite Loop in Pygments

- 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): 2.49%, higher than 85% of CVEs (2026-12-01)
- Published: 2021-03-23T16:40:22.000Z
- Modified: 2026-06-17T03:33:34.817Z
- Also known as: GHSA-9w8r-397f-prfh, PYSEC-2021-140
- Weaknesses: CWE-835
- Assigned by: redhat

## Description

An infinite loop in SMLLexer in Pygments versions 1.5 to 2.7.3 may lead to denial of service when performing syntax highlighting of a Standard ML (SML) source file, as demonstrated by input that only contains the "exception" keyword.

(As written by CVE List.)

## Affected

- python-pygments: python-pygments 2.7.4
- pygments (PyPI): from 1.5 before 2.7.4
- pygments pygments: from 1.5 up to 2.7.3
- redhat openshift_container_platform: 3.11; 4.0
- redhat openstack_platform: 10.0
- redhat software_collections: no versions given
- redhat enterprise_linux: 7.0; 8.0
- fedoraproject fedora: 33
- debian debian_linux: 9.0; 10.0

## 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://bugzilla.redhat.com/show_bug.cgi?id=1922136> (issue-tracking, patch, report, third-party-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.debian.org/debian-lts-announce/2021/05/msg00006.html> (mailing-list, third-party-advisory, web)
- <https://www.oracle.com/security-alerts/cpuoct2021.html> (not-applicable, third-party-advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-20270> (advisory)
- <https://github.com/pygments/pygments/commit/f91804ff4772e3ab41f46e28d370f57898700333> (web)
- <https://github.com/pygments/pygments> (package)
- <https://github.com/pypa/advisory-database/tree/main/vulns/pygments/PYSEC-2021-140.yaml> (web)
- <https://github.com/advisories/GHSA-9w8r-397f-prfh> (advisory)

## Sources

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

---

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