# CVE-2021-41816: Buffer overrun in CGI.escape_html

- Severity: Critical 9.8 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 5.26%, higher than 92% of CVEs (2026-12-01)
- Public exploit code or proof of concept: one link below, marked "exploit"
- Published: 2021-12-14T21:36:20.000Z
- Modified: 2026-08-13T20:11:58.269Z
- Also known as: GHSA-5cqm-crxm-6qpv
- Weaknesses: CWE-190
- Assigned by: mitre

## 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.

(As written by CVE List.)

## Affected

- Unspecified product: n/a
- cgi (RubyGems): from 0.3.0 before 0.3.1; from 0.2.0 before 0.2.1; before 0.1.0.1
- ruby-lang cgi: before 0.3.1; up to 0.2.0; up to 0.1.0
- fedoraproject fedora: 34; 35

## Every score

- GitHub: CVSS:3.1 9.8 Critical `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- NVD: CVSS:3.1 9.8 Critical `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- NVD: CVSS:2.0 7.5 High `AV:N/AC:L/Au:N/C:P/I:P/A:P`

## References

- <https://www.ruby-lang.org/en/news/2021/11/24/buffer-overrun-in-cgi-escape_html-cve-2021-41816/> (exploit, vendor-advisory)
- <https://hackerone.com/reports/1328463> (permissions-required, third-party-advisory, web)
- <https://security-tracker.debian.org/tracker/CVE-2021-41816> (third-party-advisory, web)
- <https://security.netapp.com/advisory/ntap-20220303-0006/> (third-party-advisory)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN/> (vendor-advisory)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF/> (vendor-advisory)
- <https://security.gentoo.org/glsa/202401-27> (vendor-advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-41816> (advisory)
- <https://github.com/ruby/cgi/commit/959ccf0b6a672bcc64aeaa60c6e1f9e728f1e87f> (web)
- <https://github.com/ruby/cgi/commit/ad079c1cb5f58eba1ffac46da79995fcf94a3a6e> (web)
- <https://github.com/ruby/cgi/commit/c6a37a671b556eb06140ea89cc465136b24207a6> (web)
- <https://github.com/ruby/cgi/commit/c728632c1c09d46cfd4ecbff9caaa3651dd1002a> (web)
- <https://www.ruby-lang.org/en/news/2021/11/24/buffer-overrun-in-cgi-escape_html-cve-2021-41816> (web)
- <https://security.netapp.com/advisory/ntap-20220303-0006> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF> (web)
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN> (web)
- <https://groups.google.com/g/ruby-security-ann/c/4MQ568ZG47c> (web)
- <https://github.com/rubysec/ruby-advisory-db/blob/master/gems/cgi/CVE-2021-41816.yml> (web)
- <https://github.com/ruby/cgi> (package)

## Sources

- CVE List: [CVE-2021-41816](https://www.cve.org/CVERecord?id=CVE-2021-41816), CVE Terms of Use, modified 2024-08-04
- GitHub Advisory Database: [GHSA-5cqm-crxm-6qpv](https://github.com/advisories/GHSA-5cqm-crxm-6qpv), CC-BY-4.0, modified 2026-08-13
- NVD: [CVE-2021-41816](https://nvd.nist.gov/vuln/detail/CVE-2021-41816), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2021-41816 · Whole record: https://cve.day/CVE-2021-41816.json · Rebuilt by cve.day 2026-11-25T22:58:06.784Z
