CVE-2021-41816Ruby-lang Cgi
Critical 9.8 No auth needed
Follow: this CVE · Ruby-lang · Ruby-lang Cgi We alert you by email or Slack (account required).
- Priority
- 74
- CVSS 3.1
- 9.8
- EPSS
- 4.9% probability of exploitation in 30 days · percentile 93
- Auth required
- No
- Published
- Feb 6, 2022
- Updated
- Jun 17, 2026
- Category
- Application · Cross-platform
- Weakness (CWE)
- CWE-190
- Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
What happens
CGI.escape_html in Ruby before 2.7.5 and 3.x before 3.0.3 has an integer overflow and resultant buffer overflow via a long string on platforms (such as Windows) where size_t and long have different numbers of bytes. This also affects the CGI gem before 0.3.1 for Ruby.
What to do
- Apply the vendor's security update for Cgi.
- It can be exploited without authentication: if you cannot patch now, restrict Internet access to the affected service.
Affected packages
| Ecosystem | Package | Affected versions | Fixed in | How to upgrade |
|---|---|---|---|---|
| RubyGems | cgi |
≥ 0.3.0 < 0.3.1 |
0.3.1 |
gem "cgi", ">= 0.3.1" |
| RubyGems | cgi |
≥ 0.2.0 < 0.2.1 |
0.2.1 |
gem "cgi", ">= 0.2.1" |
| RubyGems | cgi |
< 0.1.0.1 |
0.1.0.1 |
gem "cgi", ">= 0.1.0.1" |
Per OSV / GitHub Advisories (GHSA-5cqm-crxm-6qpv). Check the version in your lockfile before upgrading.
Affected products (CPE)
| Vendor | Product | Versions |
|---|---|---|
| ruby-lang | cgi | < 0.3.1 |
| ruby-lang | cgi | ≤ 0.2.0 |
| ruby-lang | cgi | ≤ 0.1.0 |
| fedoraproject | fedora | 34 |
| fedoraproject | fedora | 35 |
Official advisories
- libruby4_0-4_0-4.0.0~preview2-1.1 on GA media · SUSE · openSUSE-SU-2025:15819-1 · Dec 12, 2025 Critical
Vendor, CERT and distribution advisories that name this CVE. Original titles.
Official sources
References
Links published by the sources. Open them with care.
- hackerone.com Permissions Required Third Party Advisory
- lists.fedoraproject.org
- lists.fedoraproject.org
- security-tracker.debian.org Third Party Advisory
- security.gentoo.org
- security.netapp.com Third Party Advisory
- www.ruby-lang.org Exploit Vendor Advisory