CVE-2025-27220 — Vulnerability in cgi — CVE Details
CGI has Regular Expression Denial of Service (ReDoS) potential in Util#escapeElement
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.34%). Schedule for your next planned update.
Does your project use an affected cgi version?
Paste your Gemfile.lock to check it for CVE-2025-27220 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
There is a possibility for Regular expression Denial of Service (ReDoS) by in the cgi gem. This vulnerability has been assigned the CVE identifier CVE-2025-27220. We recommend upgrading the cgi gem.
Details
The regular expression used in CGI::Util#escapeElement is vulnerable to ReDoS. The crafted input could lead to a high CPU consumption.
This vulnerability only affects Ruby 3.1 and 3.2. If you are using these versions, please update CGI gem to version 0.3.5.1, 0.3.7, 0.4.2 or later.
Affected versions
cgi gem versions <= 0.3.5, 0.3.6, 0.4.0 and 0.4.1.
Credits
Thanks to svalkanov for discovering this issue. Also thanks to nobu for fixing this vulnerability.
Advisory Timeline
- First published March 3, 2025 (634 days ago).
- Last revised September 10, 2026 — 555 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
gem install cgi -v 0.4.2
gem install cgi -v 0.3.7
gem install cgi -v 0.3.5.1
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (3)
Affects 1 ecosystem: RubyGems (1).
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-1333
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 4.0 score means for each attack dimension.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:N/A:L
References
- https://nvd.nist.gov/vuln/detail/CVE-2025-27220ADVISORY
- https://github.com/ruby/cgi/pull/52WEB
- https://github.com/ruby/cgi/pull/53WEB
- https://github.com/ruby/cgi/pull/54WEB
- https://hackerone.com/reports/2890322WEB
- https://github.com/ruby/cgiPACKAGE
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/cgi/CVE-2025-27220.ymlWEB
- https://lists.debian.org/debian-lts-announce/2025/03/msg00008.htmlWEB
- https://www.cve.org/CVERecord?id=CVE-2025-27220WEB
- https://www.ruby-lang.org/en/news/2025/02/26/security-advisoriesWEB
Frequently Asked Questions
- What is CVE-2025-27220?
- CGI has Regular Expression Denial of Service (ReDoS) potential in Util#escapeElement. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 4.0/10).
- How do I check if my project is affected by CVE-2025-27220?
- CVE-2025-27220 affects cgi. It has a 1.3% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2025-27220 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Exploitation requires specific conditions, or the impact is limited.
This is an above-median EPSS score — 71.4% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
Also Known As
Related CVEs
- CVE-2021-41816CRITICAL
Buffer overrun in CGI.escape_html
- CVE-2021-41819HIGH
Cookie Prefix Spoofing in CGI::Cookie.parse
- CVE-2021-33621HIGH
HTTP response splitting in CGI
- CVE-2026-128084MEDIUM
sqlite3-ruby: Possible SQL query truncation when a string is 4 GiB or larger
- CVE-2025-27219MEDIUM
CGI has Denial of Service (DoS) potential in Cookie.parse
- CVE-2026-115472MEDIUM
Doorkeeper: When using public clients, any client can revoke any access token