Skip to content
Heist/ feed
Back to feed
Critical

Security advisory

Type: advisorySources: OSVCVE: CVE-2021-41816

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2021-41816
Confirmed fixed CVEs
Not specified
Updated in this feed
1 Nov 2026, 05:11 UTC · Revision 1

Source evidence

CVE-2021-41816

core-osv · Original source

Published 6 Feb 2022, 21:15 UTC

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.

osv:CVE-2021-41816
Complete source record
{
  "id": "8eb2822cbbd7ef2b207fb54f96854679485e6db3d95233964b1b8f6e4358a4c7",
  "url": "https://osv.dev/vulnerability/CVE-2021-41816",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "CVE-2021-41816",
    "summary": "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.",
    "evidence": "osv:CVE-2021-41816",
    "products": [],
    "severity": "critical",
    "structured": {
      "id": "CVE-2021-41816",
      "aliases": [
        "CVE-2021-41816",
        "GHSA-5cqm-crxm-6qpv"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/ruby/cgi",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "c9c800715ef268421ce7fbe9bc62d19a2ab67fee"
                },
                {
                  "last_affected": "8f0b2571916ed143328c1834793fe8305b891e1a"
                },
                {
                  "last_affected": "cf0564fe0e01f816c0602456333c82cc8bde8cf7"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:ruby-lang:cgi:*:*:*:*:*:ruby:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "0.3.1"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:ruby-lang:cgi:*:*:*:*:*:ruby:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "last_affected": "0.2.0"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:ruby-lang:cgi:*:*:*:*:*:ruby:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "last_affected": "0.1.0"
                      }
                    ],
                    "source": "CPE_RANGE"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v0.1.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-41816.json"
          }
        }
      ],
      "modified": "2026-10-24T10:30:25.605911957Z",
      "provider": "osv",
      "references": [
        "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN/",
        "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF/",
        "https://security-tracker.debian.org/tracker/CVE-2021-41816",
        "https://security.gentoo.org/glsa/202401-27",
        "https://security.netapp.com/advisory/ntap-20220303-0006/",
        "https://hackerone.com/reports/1328463",
        "https://www.ruby-lang.org/en/news/2021/11/24/buffer-overrun-in-cgi-escape_html-cve-2021-41816/"
      ],
      "provider_metadata": {
        "unresolved_ranges": [
          {
            "cpes": [
              "cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*",
              "cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*"
            ],
            "vendor_product": "fedoraproject:fedora",
            "extracted_events": [
              {
                "range": [
                  {
                    "introduced": "34"
                  },
                  {
                    "last_affected": "34"
                  },
                  {
                    "introduced": "35"
                  },
                  {
                    "last_affected": "35"
                  }
                ],
                "source": "CPE_STRING"
              }
            ]
          }
        ]
      }
    },
    "related_cves": [
      {
        "value": "CVE-2021-41816",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 431397,
  "published_at": "2022-02-06T21:15:07.887+00:00"
}