Vulnerabilities / CVE-2021-41816

critical

CVE-2021-41816

ruby: buffer overflow in CGI.escape_html

Published Modified CWE 190
In the Trivy database since at least 24 Oct 2026, 07:11 UTCWhen it arrived before that build is not recorded.

Severity by source

NVD9.8CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GHSA9.8CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Red Hat7.5CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Trivy's own label is CRITICAL. Rated critical by NVD, GHSA, Photon OS. Rated lower by Ruby Advisory DB (high), Red Hat (medium), Ubuntu (medium).

Description

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.

Affected packages and fixed versions

SourcePackageFixed in
Photon OS 4.0ruby, ruby-devel2.7.4-9.ph4
rubygems::GitHub Security Advisory RubyGemscgi0.3.1, 0.2.1, 0.1.0.1
alpine 3.12ruby2.7.5-r0
alpine 3.13ruby2.7.5-r0
alpine 3.14ruby2.7.5-r0
alpine 3.15ruby3.0.3-r0
alpine 3.16ruby3.0.3-r0
alpine 3.17ruby3.0.3-r0
alpine 3.18ruby3.0.3-r0
alpine 3.19ruby3.0.3-r0
alpine 3.20ruby3.0.3-r0
alpine 3.21ruby3.0.3-r0
Show all 24 entries from 23 sources
SourcePackageFixed in
Photon OS 4.0ruby2.7.4-9.ph4
Photon OS 4.0ruby-devel2.7.4-9.ph4
rubygems::GitHub Security Advisory RubyGemscgi0.3.1, 0.2.1, 0.1.0.1
alpine 3.12ruby2.7.5-r0
alpine 3.13ruby2.7.5-r0
alpine 3.14ruby2.7.5-r0
alpine 3.15ruby3.0.3-r0
alpine 3.16ruby3.0.3-r0
alpine 3.17ruby3.0.3-r0
alpine 3.18ruby3.0.3-r0
alpine 3.19ruby3.0.3-r0
alpine 3.20ruby3.0.3-r0
alpine 3.21ruby3.0.3-r0
alpine 3.22ruby3.0.3-r0
alpine 3.23ruby3.0.3-r0
alpine 3.24ruby3.0.3-r0
alpine edgeruby3.0.3-r0
debian 11ruby2.72.7.4-1+deb11u1
rubygems::Ruby Advisory Databasecgi~> 0.1.0.1, ~> 0.1.1, ~> 0.2.1, >= 0.3.1
ubuntu 20.04ruby2.72.7.0-5ubuntu1.6
ubuntu 20.04-ESMruby2.72.7.0-5ubuntu1.6
ubuntu 21.04ruby2.72.7.2-4ubuntu1.3
ubuntu 21.10ruby2.72.7.4-1ubuntu3.1
ubuntu 22.04ruby3.03.0.2-7ubuntu2

References

All 22 references

Vulnerability data compiled from the Trivy vulnerability database (trivy-db, Aqua Security, Apache License 2.0), which aggregates third-party advisories. CVE records are published by The MITRE Corporation under the CVE Terms of Use; CVE is a trademark of MITRE. This product uses data from the NVD API but is not endorsed or certified by the NVD. Severity, titles and advisory data from the GitHub Advisory Database (CC BY 4.0), Red Hat security data (CC BY 4.0) and the other sources linked on each entry. Entries may be summarised or re-formatted; the linked original is the authoritative record.