CVE-2025-27220: Cgi Denial of Service Vulnerability
MODERATECVE-2025-27220 is a MODERATE (CVSS 4.0) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Cgi libraries in the RubyGems ecosystem. The issue involves cgi has regular expression denial of service (redos) potential in util#escapeelement. Remediation is available by upgrading affected packages to version 0.3.5.1, 0.3.7, 0.4.2.
CVE-2025-27220 at a Glance
Security Impact
CVSS: 4.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:N/A:L).
How to Fix CVE-2025-27220
To remediate this vulnerability, upgrade all affected Cgi dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade cgi to 0.3.5.1
Upgrade cgi to 0.3.7
Upgrade cgi to 0.4.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for cgi
How to Check if You Are Affected
To determine whether your application is affected by CVE-2025-27220, inspect your project dependencies for Cgi:
inspect dependencies for cgi
Analyze the terminal output to locate any version of Cgi in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.5.1), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Cgi, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-27220 Affected Cgi Versions
3 component(s)References
Frequently Asked Questions
What is CVE-2025-27220?
Which Cgi versions are affected?
What version fixes CVE-2025-27220?
Is cgi affected?
What is the CVSS score of CVE-2025-27220?
What CWE is associated with CVE-2025-27220?
How can I check RubyGems dependencies for CVE-2025-27220?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-mhwm-jh88-3gjf",
"modified" : "2025-11-04T00:32:21Z",
"published" : "2025-03-03T22:05:08Z",
"aliases" : [ "CVE-2025-27220" ],
"summary" : "CGI has Regular Expression Denial of Service (ReDoS) potential in Util#escapeElement",
"details" : "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.\n\n## Details\n\nThe regular expression used in `CGI::Util#escapeElement` is vulnerable to ReDoS. The crafted input could lead to a high CPU consumption.\n\nThis 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.\n\n## Affected versions\n\ncgi gem versions <= 0.3.5, 0.3.6, 0.4.0 and 0.4.1.\n\n## Credits\n\nThanks to svalkanov for discovering this issue.\nAlso thanks to nobu for fixing this vulnerability.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:N/A:L"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "cgi"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.3.5.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "cgi"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.3.6"
}, {
"fixed" : "0.3.7"
} ]
} ],
"versions" : [ "0.3.6" ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "cgi"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.4.0"
}, {
"fixed" : "0.4.2"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-27220"
}, {
"type" : "WEB",
"url" : "https://github.com/ruby/cgi/pull/52"
}, {
"type" : "WEB",
"url" : "https://github.com/ruby/cgi/pull/53"
}, {
"type" : "WEB",
"url" : "https://github.com/ruby/cgi/pull/54"
}, {
"type" : "WEB",
"url" : "https://hackerone.com/reports/2890322"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ruby/cgi"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/cgi/CVE-2025-27220.yml"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2025/03/msg00008.html"
}, {
"type" : "WEB",
"url" : "https://www.cve.org/CVERecord?id=CVE-2025-27220"
}, {
"type" : "WEB",
"url" : "https://www.ruby-lang.org/en/news/2025/02/26/security-advisories"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1333" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-03-03T22:05:08Z",
"nvd_published_at" : "2025-03-04T00:15:31Z"
}
}