CVE-2021-27291: High severity Pygments Pygments vulnerability
A denial of service attack was discovered against pygments. Some of the regular expressions used to tokenise source code for highlighting have exponential complexity. A specially crafted input file could cause pygments to take effectively infinite time to parse, consuming CPU resources and denying access to the service.
Other sources
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.
— Microsoft
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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/pygmentsto a version that resolves this vulnerability.Fixed in 2.3.1+dfsg-1+deb10u2Fixed in 2.7.1+dfsg-2.1 - Upgrade
Upgrade
redhat/automation-hubto a version that resolves this vulnerability.Fixed in 0:4.2.2-1.el7 - Upgrade
Upgrade
redhat/python3-djangoto a version that resolves this vulnerability.Fixed in 0:2.2.18-1.el7 - Upgrade
Upgrade
redhat/python-bleachto a version that resolves this vulnerability.Fixed in 0:3.3.0-1.el7 - Upgrade
Upgrade
redhat/python-bleach-allowlistto a version that resolves this vulnerability.Fixed in 0:1.0.3-1.el7 - Upgrade
Upgrade
redhat/python-galaxy-importerto a version that resolves this vulnerability.Fixed in 0:0.2.15-1.el7 - Upgrade
Upgrade
redhat/python-galaxy-ngto a version that resolves this vulnerability.Fixed in 0:4.2.2-1.el7 - Upgrade
Upgrade
redhat/python-pulp-ansibleto a version that resolves this vulnerability.Fixed in 1:0.5.6-1.el7 - Upgrade
Upgrade
redhat/automation-hubto a version that resolves this vulnerability.Fixed in 0:4.2.2-1.el8 - Upgrade
Upgrade
redhat/python3-djangoto a version that resolves this vulnerability.Fixed in 0:2.2.18-1.el8 - Upgrade
Upgrade
redhat/python-bleachto a version that resolves this vulnerability.Fixed in 0:3.3.0-1.el8 - Upgrade
Upgrade
redhat/python-bleach-allowlistto a version that resolves this vulnerability.Fixed in 0:1.0.3-1.el8 - Upgrade
Upgrade
redhat/python-galaxy-importerto a version that resolves this vulnerability.Fixed in 0:0.2.15-1.el8 - Upgrade
Upgrade
redhat/python-galaxy-ngto a version that resolves this vulnerability.Fixed in 0:4.2.2-1.el8 - Upgrade
Upgrade
redhat/python-pulp-ansibleto a version that resolves this vulnerability.Fixed in 1:0.5.6-1.el8 - Upgrade
Upgrade
redhat/resource-agentsto a version that resolves this vulnerability.Fixed in 0:4.1.1-98.el8 - Upgrade
Upgrade
redhat/python27-babelto a version that resolves this vulnerability.Fixed in 0:0.9.6-10.el7 - Upgrade
Upgrade
redhat/python27-pythonto a version that resolves this vulnerability.Fixed in 0:2.7.18-3.el7 - Upgrade
Upgrade
redhat/python27-python-jinja2to a version that resolves this vulnerability.Fixed in 0:2.6-16.el7 - Upgrade
Upgrade
redhat/python27-python-pygmentsto a version that resolves this vulnerability.Fixed in 0:1.5-5.el7 - Upgrade
Upgrade
debian/mediawikito a version that resolves this vulnerability.Fixed in 1:1.31.16-1+deb10u2Fixed in 1:1.31.16-1+deb10u6Fixed in 1:1.35.11-1~deb11u1Fixed in 1:1.35.13-1~deb11u1Fixed in 1:1.39.4-1~deb12u1Fixed in 1:1.39.5-1~deb12u1Fixed in 1:1.39.5-1 - Upgrade
Upgrade
debian/pygmentsto a version that resolves this vulnerability.Fixed in 2.3.1+dfsg-1+deb10u2Fixed in 2.7.1+dfsg-2.1Fixed in 2.14.0+dfsg-1Fixed in 2.15.1+dfsg-1 - Upgrade
Upgrade
ubuntu/pygmentsto a version that resolves this vulnerability.Fixed in 2.7.1+dfsg-2ubuntu1 - Upgrade
Upgrade
ubuntu/pygmentsto a version that resolves this vulnerability.Fixed in 2.2.0+dfsg-1ubuntu0.2 - Upgrade
Upgrade
ubuntu/pygmentsto a version that resolves this vulnerability.Fixed in 2.3.1+dfsg-1ubuntu2.2 - Upgrade
Upgrade
ubuntu/pygmentsto a version that resolves this vulnerability.Fixed in 2.3.1+dfsg-4ubuntu0.2 - Upgrade
Upgrade
ubuntu/pygmentsto a version that resolves this vulnerability.Fixed in 2.7.4 - Upgrade
Upgrade
ubuntu/pygmentsto a version that resolves this vulnerability.Fixed in 2.1+dfsg-1ubuntu0.2 - Upgrade
Upgrade
ubuntu/pygmentsto a version that resolves this vulnerability.Fixed in 1.6+dfsg-1ubuntu1.1+ - Upgrade
Upgrade
redhat/python-pygmentsto a version that resolves this vulnerability.Fixed in 2.7.4 - Upgrade
Upgrade
pip/Pygmentsto a version that resolves this vulnerability.Fixed in 2.7.4 - Upgrade
Upgrade
pygmentsto a version that resolves this vulnerability.Fixed in 2.7.4
Event History
Parent advisories
This vulnerability appears in the following advisories.
Frequently Asked Questions
What is the vulnerability ID?
The vulnerability ID is CVE-2021-27291.
What is the severity of CVE-2021-27291?
CVE-2021-27291 has a severity value of 7, which is considered high.
What is the description of CVE-2021-27291?
CVE-2021-27291 is a denial of service attack against pygments where specially crafted input files can cause the software to take infinite time to parse, consuming CPU resources.
How do I fix CVE-2021-27291?
To fix CVE-2021-27291, update your pygments package to version 2.7.4.
Where can I find more information about CVE-2021-27291?
You can find more information about CVE-2021-27291 in the references provided: https://gist.github.com/b-c-ds/b1a2cc0c68a35c57188575eb496de5ce, https://github.com/pygments/pygments/commit/2e7e8c4a7b318f4032493773732754e418279a14, https://lists.debian.org/debian-lts-announce/2021/03/msg00024.html