CVE-2021-41816 in Fedoraproject Fedora and 2 more products
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.
Affects 3 products from 2 vendors. Facts below cite their sources.
Remotely exploitable over the network, low complexity, no authentication required, no user interaction needed, impact contained to the vulnerable component, full confidentiality impact, full integrity impact, full availability impact.
Affected products and versions
| Vendor | Product | Affected versions |
|---|---|---|
| Fedoraproject | Fedora | 34 35 |
| Ruby-Lang | Cgi | < 0.3.1 |
Platforms listed by the source (the vulnerable product runs on these; they are not themselves vulnerable): Ruby-Lang Ruby
A product listed here is affected only at the versions shown. Use the free check to test the exact version you run.
Fix and vendor advisory
Vendor PSIRT: [email protected]
Exploitation
| CISA known-exploited | Not in the CISA KEV catalog |
|---|---|
| Public exploit | Not confirmed |
Official 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.
Source: NIST NVD / MITRE CVE.
Record details
| CVE ID | CVE-2021-41816 |
|---|---|
| BreachSpider ID | BS-2022-GLOBAL-070796-C |
| CVSS vector | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| Published | 2022-02-06 |
| Last modified | 2026-06-17 |
| Weakness (CWE) | |
| Source | NVD |
Weakness definitions
CWE-190: Integer Overflow or Wraparound
Arithmetic operation exceeds the maximum integer value, wrapping around and often leading to undersized allocations.
Related attack patterns (CAPEC)
CAPEC-92 Forced Integer Overflow via CWE-190
Mapping is CWE to CAPEC per MITRE CAPEC 3.9.
Analysis AI-written, not human-reviewed
CVE-2021-41816 affects Ruby versions before 2.7.5 and 3.x before 3.0.3, as well as the CGI gem before 0.3.1, due to an integer overflow and resultant buffer overflow in the CGI.escape_html function when processing long strings on certain platforms.
An attacker can exploit this vulnerability by providing a specially crafted long string to the CGI.escape_html function, leading to a buffer overflow. This can potentially allow for arbitrary code execution or denial of service.
Questions
What is CVE-2021-41816?
CVE-2021-41816 affects Ruby versions before 2.7.5 and 3.x before 3.0.3, as well as the CGI gem before 0.3.1, due to an integer overflow and resultant buffer overflow in the CGI.escape_html function when processing long strings on certain platforms.
What is the CVSS score for CVE-2021-41816?
CVE-2021-41816 has CVSS 9.8 (Critical). Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H. EPSS: 5.3%.
Is CVE-2021-41816 actively exploited?
No confirmed active exploitation of CVE-2021-41816 as of 2026-09-25.
How do I remediate CVE-2021-41816?
Priority: IMMEDIATE. Advisory: https://www.ruby-lang.org/en/news/2021/11/24/buffer-overrun-in-cgi-escape_html-cve-2021-41816/ PSIRT: [email protected]
What systems are affected by CVE-2021-41816?
CVE-2021-41816 affects Fedoraproject Fedora; Ruby-Lang Cgi.
For developers and AI agents
Run this check from your own code or agent
REST API
curl -s https://breachspider.com/api/v1/assets/correlate-cves \
-H "Authorization: Bearer $BREACHSPIDER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"assets":[{"asset_id":"dev-1","vendor":"Fedoraproject","product":"Fedora","version":"1.0"}]}'
MCP for AI agents
# hosted: add as a connector
https://mcp.breachspider.com/mcp
# local
pipx install breachspider-mcp
Free trial: 14 days, 750 device checks, no card.
Page facts from NVD, MITRE, CISA and vendor advisories, record last modified 2026-06-17.