CVE-2021-27291 json
Pygments vulnerable to Regular Expression Denial of Service (ReDoS)
published 2021-03-17 5 y ago modified 2026-06-17 4 mo ago also GHSA-pq64-v7f5-gqh8 , PYSEC-2021-141 , EUVD-2021-0208
- cvss
- 7.5
- version 3.1, NVD
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 3.9%
- EPSS 3.9% chance of exploitation in 30 days, percentile 90%
- public exploits
- 0
- none known
Summary
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.
Patch / fix
- pypi pygments 2.7.4
- pygments pygments 2.7.4
- pygments Debian 14, Debian 13, Debian 12 2.7.1+dfsg-2.1
- mediawiki Debian 14, Debian 13, Debian 12 1:1.35.2-1
debian advisories DEBIAN-CVE-2021-27291
- pygments Ubuntu 16.04 LTS 2.1+dfsg-1ubuntu0.2
- pygments Ubuntu 18.04 LTS 2.2.0+dfsg-1ubuntu0.2
- pygments Ubuntu 20.04 LTS 2.3.1+dfsg-1ubuntu2.2
- pygments Ubuntu Pro 14.04 LTS 1.6+dfsg-1ubuntu1.1+esm1
ubuntu advisories UBUNTU-CVE-2021-27291
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, SLES 15-LTSS, SLE Module for Package Hub 15 SP3 +3 more 2.2.0-4.9.1
- python-Pygments SLES for SAP 15 SP1, SLES 15 SP1-LTSS, SLES 15 SP1-BCL +4 more 2.6.1-7.10.1
- python-Pygments SLE Module for Basesystem 15 SP3 2.6.1-4.3.1
- python-Pygments SLE Module for Public Cloud 12 2.4.2-10.7.1
suse advisories SUSE-SU-2021:3841-1SUSE-SU-2021:3840-1SUSE-SU-2021:3839-1SUSE-SU-2021:3814-1
- python-Pygments openSUSE Leap 15.2 2.6.1-lp152.5.12.1
- python-Pygments openSUSE Leap 15.3 2.2.0-4.9.1
- python-Pygments openSUSE Leap 15.3 2.6.1-4.3.1
opensuse advisories openSUSE-SU-2021:1521-1openSUSE-SU-2021:3841-1openSUSE-SU-2021:3839-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.11 2.5.2-r1
- py3-pygments Alpine 3.12 2.6.1-r1
alpine advisories ALPINE-CVE-2021-27291
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-35138AZL-6812
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
Vendor 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-27291 updated cvss 7.5
python-pygments: ReDoS in multiple lexers
-
Red Hat Enterprise Linux 6 python-pygments Red Hat Enterprise Linux 7 python-pygments, resource-agents, resource-agents-gcp, resource-agents-sap, sap-cluster-connector, resource-agents-aliyun, +2 more 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 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
3.91% chance of exploitation in the next 30 days, higher than 90% of all scored CVEs (FIRST EPSS, 2026-11-08).
Exploits and checks
- gist.github.com https://gist.github.com/b-c-ds/b1a2cc0c68a35c57188575eb496de5ce referenced PoC, tagged "exploit" by a source, unverified
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.1, <2.7.4 |
2.7.4 |
Classification
References
-
github.com
/pygments/pygments/commit/2e7e8c4a7b318f4032493773732754e418279a14
web, patch, third-party-advisory
-
gist.github.com
/b-c-ds/b1a2cc0c68a35c57188575eb496de5ce
web, exploit, third-party-advisory
-
debian.org
/security/2021/dsa-4878
vendor-advisory, web, third-party-advisory, advisory
-
debian.org
/security/2021/dsa-4889
vendor-advisory, web, third-party-advisory, advisory
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55/
vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ/
vendor-advisory
-
lists.debian.org
/debian-lts-announce/2021/03/msg00024.html
mailing-list, web, third-party-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
-
nvd.nist.gov
/vuln/detail/CVE-2021-27291
advisory
-
github.com
/pygments/pygments
package
-
github.com
/pypa/advisory-database/tree/main/vulns/pygments/PYSEC-2021-141.yaml
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ/
web
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55/
web
-
github.com
/advisories/GHSA-pq64-v7f5-gqh8
advisory
Sources
- CVE List CVE-2021-27291
- GitHub Advisory GHSA-pq64-v7f5-gqh8
- NVD CVE-2021-27291
- OSV PYSEC-2021-141
Fencer Vulns 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.