CVE-2021-20270 json
Infinite Loop in Pygments
published 5y ago modified 4mo ago also GHSA-9w8r-397f-prfh , PYSEC-2021-140 , EUVD-2021-0207
- cvss
- 7.5
- version 3.1, NVD
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 2.8%
- EPSS 2.8% chance of exploitation in 30 days, percentile 86%
- public exploits
- 0
- none known
Summary
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.
Patch / fix
- pypi pygments 2.7.4
- pygments Debian 14, Debian 13, Debian 12 2.7.1+dfsg-2
- mediawiki Debian 14, Debian 13, Debian 12 1:1.35.2-1
debian advisories DEBIAN-CVE-2021-20270
- pygments Ubuntu 16.04 LTS 2.1+dfsg-1ubuntu0.1
- pygments Ubuntu 18.04 LTS 2.2.0+dfsg-1ubuntu0.1
- pygments Ubuntu 20.04 LTS 2.3.1+dfsg-1ubuntu2.1
- pygments Ubuntu Pro 14.04 LTS 1.6+dfsg-1ubuntu1.1+esm1
ubuntu advisories UBUNTU-CVE-2021-20270
Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- pytz RHEL 8 2017.2-12.module+el8.1.0+3111+de3f2d8e
- babel RHEL 8 2.5.1-10.module+el8.5.0+11014+88fc0d0b
- numpy RHEL 8 1:1.14.2-16.module+el8.4.0+9406+221a4565
- scipy RHEL 8 1.0.0-21.module+el8.5.0+10858+05337455
- Cython RHEL 8 0.28.1-7.module+el8.1.0+3111+de3f2d8e
- pytest RHEL 8 3.4.2-13.module+el8.1.0+3111+de3f2d8e
- PyYAML RHEL 8 3.12-16.module+el8.1.0+3111+de3f2d8e
- python2 RHEL 8 2.7.18-7.module+el8.5.0+12203+77770ab7
red hat advisories RHSA-2021:4151RHSA-2021:3252RHSA-2021:0781RHSA-2021:4139RHSA-2021:4150
- python-Pygments SLES for SAP 15 SP1, SLES 15 SP1-LTSS, SLES 15 SP1-BCL +4 more 2.6.1-7.7.1
- python-Pygments SLES for SAP 15, SLES 15-LTSS, SLE Module for Package Hub 15 SP3 +3 more 2.2.0-4.6.1
suse advisories SUSE-SU-2021:3473-1SUSE-SU-2021:1500-1
- python-Pygments openSUSE Tumbleweed 2.21.0-1.1
- python-Pygments openSUSE Leap 15.2 2.6.1-lp152.5.9.1
opensuse advisories openSUSE-SU-2026:11568-1openSUSE-SU-2021:1402-1
- babel AlmaLinux 8 2.5.1-10.module_el8.6.0+2781+fed64c13
- python2-py AlmaLinux 8 1.5.3-6.module_el8.6.0+2781+fed64c13
- python2-dns AlmaLinux 8 1.15.0-10.module_el8.6.0+2781+fed64c13
- python2-six AlmaLinux 8 1.11.0-6.module_el8.6.0+2781+fed64c13
- python2-bson AlmaLinux 8 3.7.0-1.module_el8.6.0+2781+fed64c13
- python2-idna AlmaLinux 8 2.5-7.module_el8.6.0+2781+fed64c13
- python2-mock AlmaLinux 8 2.0.0-13.module_el8.6.0+2781+fed64c13
- python2-nose AlmaLinux 8 1.3.7-31.module_el8.6.0+2781+fed64c13
almalinux advisories ALSA-2021:4151ALSA-2021:4150ALSA-2021:4139
- pytz Rocky Linux 8 2017.2-12.module+el8.5.0+706+735ec4b3
- pytz Rocky Linux 8 2017.2-12.module+el8.4.0+403+9ae17a31
- babel Rocky Linux 8 2.5.1-10.module+el8.5.0+706+735ec4b3
- numpy Rocky Linux 8 1:1.14.2-16.module+el8.5.0+706+735ec4b3
- numpy Rocky Linux 8 1:1.14.2-16.module+el8.4.0+403+9ae17a31
- scipy Rocky Linux 8 1.0.0-21.module+el8.5.0+671+195e4563
- Cython Rocky Linux 8 0.28.1-7.module+el8.5.0+706+735ec4b3
- Cython Rocky Linux 8 0.28.1-7.module+el8.4.0+403+9ae17a31
rocky linux advisories RLSA-2021:4151RLSA-2021:4150RLSA-2021:4139
- py3-pygments Alpine 3.24, Alpine 3.23, Alpine 3.22 +8 more 2.7.4-r0
alpine advisories ALPINE-CVE-2021-20270
Alpine secdb © Alpine Linux, from https://secdb.alpinelinux.org via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- python-pygments Azure Linux 3.0 2.7.4-1
- python-pygments CBL-Mariner 2.0 2.4.2-7
azure linux advisories AZL-35137AZL-6811
Azure Linux vulnerability data, Copyright (c) Microsoft Corporation, from https://github.com/microsoft/AzureLinuxVulnerabilityData via OSV, under the MIT licence; changed: normalised to fixed package versions per release. MIT
Is CVE-2021-20270 in your dependencies? Fencer shows which of your repositories are affected as soon as an advisory lands, and opens the fix as a pull request.
Check with FencerVendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2021-20270 updated cvss 7.5
python-pygments: Infinite loop in SML lexer may lead to DoS
-
Red Hat Enterprise Linux 7 resource-agents, resource-agents-gcp, resource-agents-sap, sap-cluster-connector, resource-agents-aliyun, resource-agents-sap-hana, +1 moreaffected: no fix planned “Out of support scope”
-
Red Hat OpenShift Container Platform 3.11 google-cloud-sdkaffected: no fix available “Fix deferred”
-
Red Hat OpenShift Container Platform 4 google-cloud-sdk Red Hat OpenStack Platform 10 (Newton) python-pygmentsaffected: no fix planned “Out of support scope”
-
Red Hat Automation Hub 4.2 for RHEL 7 python-bleach 3.3.0-1.el7pc, automation-hub 4.2.2-1.el7pc, python3-bleach 3.3.0-1.el7pc, python3-django 2.2.18-1.el7pc, python-galaxy-ng 4.2.2-1.el7pc, python3-galaxy-ng 4.2.2-1.el7pc, +6 more Red Hat Automation Hub 4.2 for RHEL 8 python-bleach 3.3.0-1.el8pc, automation-hub 4.2.2-1.el8pc, python3-bleach 3.3.0-1.el8pc, python3-django 2.2.18-1.el8pc, python-galaxy-ng 4.2.2-1.el8pc, python3-galaxy-ng 4.2.2-1.el8pc, +6 morefixed: vendor fix RHSA-2021:0781
-
Red Hat Enterprise Linux AppStream (v. 8) pytz 2017.2-12.module+el8.1.0+3111+de3f2d8e, PyYAML 3.12-16.module+el8.1.0+3111+de3f2d8e, babel 2.5.1-10.module+el8.5.0+11014+88fc0d0b, Cython 0.28.1-7.module+el8.1.0+3111+de3f2d8e, numpy 1.14.2-16.module+el8.4.0+9406+221a4565, pytest 3.4.2-13.module+el8.1.0+3111+de3f2d8e, +108 morefixed: vendor fix RHSA-2021:4151
-
Red Hat Enterprise Linux High Availability (v. 8) resource-agents 4.1.1-98.el8, resource-agents-gcp 4.1.1-98.el8, resource-agents-paf 4.1.1-98.el8, resource-agents-aliyun 4.1.1-98.el8 Red Hat Enterprise Linux Resilient Storage (v. 8) resource-agents 4.1.1-98.el8, resource-agents-gcp 4.1.1-98.el8, resource-agents-paf 4.1.1-98.el8, resource-agents-aliyun 4.1.1-98.el8fixed: vendor fix RHSA-2021:4139
-
Red Hat Software Collections for Red Hat Enterprise Linux Server (v. 7) python27-babel 0.9.6-10.el7, python27-python 2.7.18-3.el7, python27-tkinter 2.7.18-3.el7, python27-python-jinja2 2.6-16.el7, python27-python-libs 2.7.18-3.el7, python27-python-test 2.7.18-3.el7, +3 more Red Hat Software Collections for Red Hat Enterprise Linux Server EUS (v. 7.7) python27-babel 0.9.6-10.el7, python27-python 2.7.18-3.el7, python27-tkinter 2.7.18-3.el7, python27-python-jinja2 2.6-16.el7, python27-python-libs 2.7.18-3.el7, python27-python-test 2.7.18-3.el7, +3 more Red Hat Software Collections for Red Hat Enterprise Linux Workstation (v. 7) python27-babel 0.9.6-10.el7, python27-python 2.7.18-3.el7, python27-tkinter 2.7.18-3.el7, python27-python-jinja2 2.6-16.el7, python27-python-libs 2.7.18-3.el7, python27-python-test 2.7.18-3.el7, +3 morefixed: vendor fix RHSA-2021:3252
-
Red Hat Enterprise Linux 6 python-pygments Red Hat Enterprise Linux 7 python-pygments Red Hat Enterprise Linux 9 python3-pygmentsnot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
Exploit prediction
2.76% chance of exploitation in the next 30 days, higher than 86% of all scored CVEs (FIRST EPSS, 2026-11-09).
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| NVD | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 2.0 | 5.0 | AV:N/AC:L/Au:N/C:N/I:N/A:P |
| GitHub | 3.1 | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| pypi | pygments | >=1.5, <2.7.4 |
2.7.4 |
Affected products
- n/a python-pygments
Classification
- Weakness
-
- CWE-835 Loop with Unreachable Exit Condition
References
-
bugzilla.redhat.com
/show_bug.cgi?id=1922136
web, issue-tracking, patch, third-party-advisory, report
-
github.com
/pygments/pygments/commit/f91804ff4772e3ab41f46e28d370f57898700333
web
-
debian.org
/security/2021/dsa-4889
vendor-advisory, web, third-party-advisory, advisory
-
lists.debian.org
/debian-lts-announce/2021/05/msg00003.html
mailing-list, web, third-party-advisory
-
lists.debian.org
/debian-lts-announce/2021/05/msg00006.html
mailing-list, web, third-party-advisory
-
oracle.com
/security-alerts/cpuoct2021.html
web, not-applicable, third-party-advisory
-
nvd.nist.gov
/vuln/detail/CVE-2021-20270
advisory
-
github.com
/pygments/pygments
package
-
github.com
/pypa/advisory-database/tree/main/vulns/pygments/PYSEC-2021-140.yaml
web
-
github.com
/advisories/GHSA-9w8r-397f-prfh
advisory
Sources
- CVE List CVE-2021-20270
- GitHub Advisory GHSA-9w8r-397f-prfh
- NVD CVE-2021-20270
- OSV PYSEC-2021-140
Fencer Intel keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.