CVE-2021-41816: Buffer Overflow

Published Nov 24, 2021
·
Updated

A buffer overrun vulnerability was discovered in CGI.escapehtml. This can lead to a buffer overflow when a user passes a very large string (> 700 MB) to CGI.escapehtml on a platform where long type takes 4 bytes, typically, Windows.

Other sources

A flaw was found in the ruby. This issue occurs due to improper bounds checking by a buffer overrun in CGI.escapehtml. By sending an overly long string using the sizet parameter, a remote attacker could overflow a buffer and execute arbitrary code on the system.

A security vulnerability that causes buffer overflow when you pass a very large string (> 700 MB) to CGI.escapehtml on a platform where long type takes 4 bytes, typically, Windows.

Reference: https://www.ruby-lang.org/en/news/2021/11/24/buffer-overrun-in-cgi-escapehtml-cve-2021-41816/

Red Hat

CGI.escapehtml 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 sizet and long have different numbers of bytes. This also affects the CGI gem before 0.3.1 for Ruby.

Affected Software

17 affected componentsFixes available
redhat/rh-ruby30-ruby<0:3.0.4-149.el7
0:3.0.4-149.el7
redhat/rh-ruby27-ruby<0:2.7.6-131.el7
0:2.7.6-131.el7
rubygems/cgi<0.1.0.1
0.1.0.1
rubygems/cgi>=0.2.0<0.2.1
0.2.1
rubygems/cgi>=0.3.0<0.3.1
0.3.1
ruby-lang Cgi Ruby<0.3.1
All of the following
ruby-lang Ruby>=3.0.0<3.0.3
ruby-lang Cgi Ruby<=0.2.0
All of the following
ruby-lang Ruby>=2.7.0<2.7.5
ruby-lang Cgi Ruby<=0.1.0
Fedoraproject Fedora=34
Fedoraproject Fedora=35
ruby-lang Cgi Ruby<=0.2.0
ruby-lang Ruby>=3.0.0<3.0.3
ruby-lang Cgi Ruby<=0.1.0
ruby-lang Ruby>=2.7.0<2.7.5
debian/ruby2.7
2.7.4-1+deb11u12.7.4-1+deb11u5

Event History

Nov 24, 2021
CVE Published
12:00 AM
Nov 25, 2021
Data Sourced
via Red Hat·06:05 PM
DescriptionSeverityAffected Software
Dec 14, 2021
Advisory Published
via GitHub·09:36 PM
Feb 6, 2022
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
Description
Feb 24, 2026
Data Sourced
via Debian·09:46 PM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What is CVE-2021-41816?

CVE-2021-41816 is a buffer overrun vulnerability in CGI.escape_html in Ruby before 2.7.5 and 3.x before 3.0.3.

2

How severe is CVE-2021-41816?

CVE-2021-41816 has a severity rating of 9.8, which is considered critical.

3

Which software versions are affected by CVE-2021-41816?

CGI.escape_html in Ruby versions before 2.7.5 and 3.x before 3.0.3 are affected.

4

How can I fix CVE-2021-41816?

To fix CVE-2021-41816, upgrade to Ruby version 2.7.5 or 3.0.3, or apply the appropriate remedy provided by the software vendor.

5

Where can I find more information about CVE-2021-41816?

You can find more information about CVE-2021-41816 in the references section of the vulnerability report.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203