# CVE-2025-27220: CGI has Regular Expression Denial of Service (ReDoS) potential in Util#escapeElement

> An attacker can cause a denial of service in Ruby applications using the CGI gem by exploiting a Regular Expression Denial of Service vulnerability in the escapeElement method.

- **Severity:** Medium 4.0 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 3 Mar 2025
- **Updated:** 3 Nov 2025
- **Also known as:** AZL-57791, AZL-57938, CLEANSTART-2026-HJ24461, CLEANSTART-2026-QG16537, DEBIAN-CVE-2025-27220, ECHO-edf3-cb70-6d3e, GHSA-mhwm-jh88-3gjf, MINI-2wvv-m9c2-w53p, MINI-49jr-937q-vx25, MINI-cr6c-4q8v-9pq4, MINI-g3g5-ghh3-73cw, MINI-h83f-xfjx-qhqq, MINI-hgqx-qqw9-vr8x, MINI-jpgx-h29f-cpw7, MINI-jvpw-x8wj-36rp, MINI-mcw7-xvch-4wp2, MINI-qr83-65c3-3p4m, MINI-v7jm-jpr4-x324, MINI-wcpv-vhcx-3jfh, MINI-x449-3rrp-g8vq, UBUNTU-CVE-2025-27220

## What is CVE-2025-27220?

CVE-2025-27220 is a medium-severity denial of service vulnerability in ruby-lang CGI, published on 3 Mar 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

In the CGI gem before 0.4.2 for Ruby, a Regular Expression Denial of Service (ReDoS) vulnerability exists in the Util#escapeElement method.

Weakness: CWE-1333 (Inefficient Regular Expression Complexity)

## Which versions are affected by CVE-2025-27220?

6 open source packages ship an affected version, including cgi. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cgi` | RubyGems | All versions | 0.3.5.1 |
| `cgi` | RubyGems | All versions | 0.3.5.1 |
| `cgi` | RubyGems | From 0.3.6 | 0.3.7 |
| `cgi` | RubyGems | From 0.3.6 | 0.3.7 |
| `cgi` | RubyGems | From 0.4.0 | 0.4.2 |
| `cgi` | RubyGems | From 0.4.0 | 0.4.2 |

Products: Ruby-Lang Cgi.

## How do I fix CVE-2025-27220?

Upgrade cgi to a fixed version for your release line: 0.3.5.1, 0.3.7 or 0.4.2.

## Is CVE-2025-27220 being exploited?

There is no known exploitation of CVE-2025-27220 in the wild and no public exploit code.

## Other vulnerabilities in ruby-lang CGI

- [CVE-2025-27219](https://insights.sbomify.com/CVE-2025-27219/): CGI has Denial of Service (DoS) potential in Cookie.parse (medium 5.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-27220 and fix it if it is affected.

What it is: CVE-2025-27220 is a medium-severity denial of service vulnerability in ruby-lang CGI, published on 3 Mar 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-27220 in the wild and no public exploit code.

Affected packages and fixed versions:
- cgi (RubyGems): affected all versions; fixed in 0.3.5.1
- cgi (RubyGems): affected all versions; fixed in 0.3.5.1
- cgi (RubyGems): affected from 0.3.6; fixed in 0.3.7
- cgi (RubyGems): affected from 0.3.6; fixed in 0.3.7
- cgi (RubyGems): affected from 0.4.0; fixed in 0.4.2
- cgi (RubyGems): affected from 0.4.0; fixed in 0.4.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-27220/ (Markdown: https://insights.sbomify.com/CVE-2025-27220/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-27220
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-27220
- OSV: https://osv.dev/vulnerability/CVE-2025-27220

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-27220/
Summaries are generated and may contain mistakes; the official description above is the record.
