CGI.escape_html in Ruby before 2.7.5 and 3.x before 3.0.3 has an integer overflow and…
Priority MEDIUM 50CWE-190Published · Updated
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · NVD. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-190 and the CVSS impact.
Summary
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.
Why it matters now
EPSS 0.04898 92nd percentileScored 2026-11-07
Public exploit Yes 1 exploit referenceTagged by NVD
Fix Fixed cgi (RubyGems): 0.3.1, 0.2.1, 0.1.0.1Red Hat: 2 advisories
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | — | all versions | — | No fix listed | CNA |
| — | cgi (RubyGems) | 0.3.0 to before 0.3.1 | 0.3.1 | Patch available | GHSA-5cqm-crxm-6qpv |
| — | cgi (RubyGems) | 0.2.0 to before 0.2.1 | 0.2.1 | Patch available | GHSA-5cqm-crxm-6qpv |
| — | cgi (RubyGems) | before 0.1.0.1 | 0.1.0.1 | Patch available | GHSA-5cqm-crxm-6qpv |
- — Vendor— Affected all versions Fixed in — No fix listed CNA
- cgi (RubyGems) Vendor— Affected 0.3.0 to before 0.3.1 Fixed in 0.3.1 Patch available GHSA-5cqm-crxm-6qpv
- cgi (RubyGems) Vendor— Affected 0.2.0 to before 0.2.1 Fixed in 0.2.1 Patch available GHSA-5cqm-crxm-6qpv
- cgi (RubyGems) Vendor— Affected before 0.1.0.1 Fixed in 0.1.0.1 Patch available GHSA-5cqm-crxm-6qpv
CPE configurations NVD · 6
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:ruby-lang:cgi:*:*:*:*:*:ruby:*:* | before 0.3.1; up to 0.2.0 | Vulnerable | ruby |
| cpe:2.3:a:ruby-lang:ruby:*:*:*:*:*:*:*:* | 3.0.0 to before 3.0.3 | Running on | ruby |
| cpe:2.3:a:ruby-lang:cgi:*:*:*:*:*:ruby:*:* | up to 0.1.0 | Vulnerable | ruby |
| cpe:2.3:a:ruby-lang:ruby:*:*:*:*:*:*:*:* | 2.7.0 to before 2.7.5 | Running on | ruby |
| cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:* | 34 | Vulnerable | Fedoraproject |
| cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* | 35 | Vulnerable | Fedoraproject |
- cpe:2.3:a:ruby-lang:cgi:*:*:*:*:*:ruby:*:* Versions before 0.3.1; up to 0.2.0 Vulnerable ·ruby
- cpe:2.3:a:ruby-lang:ruby:*:*:*:*:*:*:*:* Versions 3.0.0 to before 3.0.3 Running on ·ruby
- cpe:2.3:a:ruby-lang:cgi:*:*:*:*:*:ruby:*:* Versions up to 0.1.0 Vulnerable ·ruby
- cpe:2.3:a:ruby-lang:ruby:*:*:*:*:*:*:*:* Versions 2.7.0 to before 2.7.5 Running on ·ruby
- cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:* Versions 34 Vulnerable ·Fedoraproject
- cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* Versions 35 Vulnerable ·Fedoraproject
Remediation
- Fix · GHSA-5cqm-crxm-6qpv cgi (RubyGems) Fixed in 0.3.1 Advisory →
- Fix · GHSA-5cqm-crxm-6qpv cgi (RubyGems) Fixed in 0.2.1 Advisory →
- Fix · GHSA-5cqm-crxm-6qpv cgi (RubyGems) Fixed in 0.1.0.1 Advisory →
Red Hat 2 advisories
- RHSA-2022:6856 Released 2022-10-11 · Red Hat rating Moderaterh-ruby27-ruby security, bug fix, and enhancement update
- Red Hat Software Collections for RHEL Workstation(v. 7) rh-ruby27-ruby-2.7.6-131.el7, rh-ruby27-ruby-devel-2.7.6-131.el7, rh-ruby27-ruby-doc-2.7.6-131.el7 +19
- Red Hat Software Collections for RHEL(v. 7) rh-ruby27-ruby-2.7.6-131.el7, rh-ruby27-ruby-devel-2.7.6-131.el7, rh-ruby27-ruby-doc-2.7.6-131.el7 +19
- RHSA-2022:6855 Released 2022-10-11 · Red Hat rating Moderaterh-ruby30-ruby security, bug fix, and enhancement update
- Red Hat Software Collections for RHEL Workstation(v. 7) rh-ruby30-ruby-3.0.4-149.el7, rh-ruby30-ruby-default-gems-3.0.4-149.el7, rh-ruby30-ruby-devel-3.0.4-149.el7 +18
- Red Hat Software Collections for RHEL(v. 7) rh-ruby30-ruby-3.0.4-149.el7, rh-ruby30-ruby-default-gems-3.0.4-149.el7, rh-ruby30-ruby-devel-3.0.4-149.el7 +18
Vendor assessments
Red Hat
Red Hat rating: Moderate. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat Software Collections for RHEL Workstation(v. 7) | Fixed | RHSA-2022:6855, RHSA-2022:6856 |
| Red Hat Software Collections for RHEL(v. 7) | Fixed | RHSA-2022:6855, RHSA-2022:6856 |
Not affected: 5 products
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
- Red Hat Software Collections
Timeline
- 2026-10-02 Threatist record created from CVE-2021-41816
- 2026-10-03 Alias added: GHSA-5cqm-crxm-6qpv
References
Exploit 1
Advisory 7
Other 13
- https://github.com/ruby/cgi/commit/959ccf0b6a672bcc64aeaa60c6e1f9e728f1e87f
- https://github.com/ruby/cgi/commit/ad079c1cb5f58eba1ffac46da79995fcf94a3a6e
- https://github.com/ruby/cgi/commit/c6a37a671b556eb06140ea89cc465136b24207a6
- https://github.com/ruby/cgi/commit/c728632c1c09d46cfd4ecbff9caaa3651dd1002a
- https://www.ruby-lang.org/en/news/2021/11/24/buffer-overrun-in-cgi-escape_html-cve-2021-41816
- https://security.netapp.com/advisory/ntap-20220303-0006
- https://lists.fedoraproject.org/archives/list/[email protected]/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF
- https://lists.fedoraproject.org/archives/list/[email protected]/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN
- https://groups.google.com/g/ruby-security-ann/c/4MQ568ZG47c
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/cgi/CVE-2021-41816.yml
- https://github.com/ruby/cgi
Sources
- CVE-2021-41816 · CVE Program
- CVE-2021-41816 · NVD
- FIRST EPSS
- GHSA-5cqm-crxm-6qpv · GitHub Advisory Database · CC BY 4.0
- CVE-2021-41816 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences