Live threats

All CVEs / Ruby-lang

CVE-2021-41816Ruby-lang Cgi

Critical 9.8 No auth needed

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.

Original NVD text.

What to do

  1. Apply the vendor's security update for Cgi.
  2. It can be exploited without authentication: if you cannot patch now, restrict Internet access to the affected service.

Affected packages

EcosystemPackageAffected versionsFixed inHow 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)

VendorProductVersions
ruby-langcgi< 0.3.1
ruby-langcgi≤ 0.2.0
ruby-langcgi≤ 0.1.0
fedoraprojectfedora34
fedoraprojectfedora35

Official advisories

Vendor, CERT and distribution advisories that name this CVE. Original titles.

Official sources

References

Links published by the sources. Open them with care.