CVE-2021-27291
Python vulnerability analysis and mitigation

Overview

CVE-2021-27291 affects Pygments versions 1.1+ up to 2.7.4, a syntax highlighting library for Python. The vulnerability was discovered by Ben Caller from Doyensec and disclosed in March 2021. The issue affects the lexers used to parse programming languages, which rely heavily on regular expressions (Doyensec Advisory).

Technical details

The vulnerability stems from regular expressions that have exponential or cubic worst-case complexity in various lexers. Multiple vulnerable patterns were identified across different language parsers, including ODIN, CADL, Factor, Ceylon, Matlab, and others. For example, one vulnerable pattern '[+-]?(\d+)*.\d+%?' in archetype.py has exponential complexity. The CVSS v3.1 base score is 7.5 (High), with the vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H (NVD).

Impact

By crafting malicious input, an attacker can cause a denial of service (DoS) through Regular Expression Denial of Service (ReDoS). The vulnerability affects multiple programming language parsers, and when exploited, can cause the application to hang or consume excessive CPU resources (Doyensec Advisory).

Mitigation and workarounds

The vulnerability was fixed in Pygments version 2.7.4 by modifying the regular expressions to avoid overlapping capture groups. The fix was implemented in commit 2e7e8c4 on January 11, 2021, and the patched version was released on January 12, 2021. Various Linux distributions have also released security updates to address this vulnerability (Pygments Commit).

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2025-67511CRITICAL9.6
  • PythonPython
  • cai-framework
NoNoDec 11, 2025
CVE-2025-13780CRITICAL9.1
  • PythonPython
  • pgadmin4
NoYesDec 11, 2025
CVE-2025-67644HIGH7.3
  • PythonPython
  • langgraph-checkpoint-sqlite
NoYesDec 11, 2025
CVE-2025-67720MEDIUM6.5
  • PythonPython
  • pyrofork
NoYesDec 11, 2025
CVE-2025-67485MEDIUM5.3
  • PythonPython
  • mad-proxy
NoNoDec 10, 2025

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management