CVE-2021-41819
Description
CGI::Cookie.parse in Ruby through 2.6.8 mishandles security prefixes in cookie names. This also affects the CGI gem through 0.3.0 for Ruby.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
CVE-2021-41819: Ruby's CGI::Cookie.parse mishandles security prefixes via URL decoding, enabling prefix spoofing.
Vulnerability
CVE-2021-41819 is a cookie prefix spoofing vulnerability in CGI::Cookie.parse in Ruby through 2.6.8 and in the cgi gem through 0.3.0 for Ruby 2.7 and 3.0 [1][4]. The method applied URL decoding to cookie names, which allowed an attacker to spoof the __Secure- or __Host- security prefixes that browsers use to enforce cookie attributes [4]. Affected versions include Ruby 2.6.8 and earlier, cgi gem 0.1.0 or earlier (bundled with Ruby 2.7 series prior to 2.7.5), cgi gem 0.2.0 or earlier (bundled with Ruby 3.0 series prior to 3.0.3), and cgi gem 0.3.0 or earlier [4].
Exploitation
An attacker who can control a cookie name (for example, by injecting a specially crafted cookie into an HTTP response from a subdomain or a non-secure origin) can exploit this flaw. By URL-encoding the prefix in the cookie name (e.g., __%53ecure- instead of __Secure-), the attacker can cause CGI::Cookie.parse to decode the name and treat the cookie as having a security prefix that it does not actually possess [4]. The attacker requires only the ability to set a cookie with a manipulated name; no special authentication or network position is needed beyond that necessary to inject the cookie into the victim's browser [4].
Impact
Successful exploitation allows an attacker to spoof security cookie prefixes, potentially bypassing browser-enforced security attributes such as Secure or Path. This could trick a vulnerable application into trusting a cookie as having come from a secure, host-locked origin when it did not, leading to session hijacking, cross-site request forgery, or other attacks that rely on cookie integrity [4]. The impact is limited to applications that inspect cookie prefixes to enforce security policies.
Mitigation
Ruby upstream released fixes on 2021-11-24 [4]. Users of Ruby 2.7 or 3.0 should update the cgi gem to version 0.3.1, 0.2.1, or 0.1.1 or later; alternatively, update Ruby to 2.7.5 or 3.0.3. Users of Ruby 2.6 should update Ruby to 2.6.9 (the cgi gem cannot be updated independently for that series). For Ruby 2.5 and earlier, which are end-of-life, no patch is available and upgrading to a supported Ruby version is recommended [4].
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
cgiRubyGems | >= 0.3.0, < 0.3.1 | 0.3.1 |
cgiRubyGems | >= 0.2.0, < 0.2.1 | 0.2.1 |
cgiRubyGems | < 0.1.0.1 | 0.1.0.1 |
Affected products
46- Ruby/CGI::Cookie.parsedescription
- osv-coords45 versionspkg:bitnami/rubypkg:bitnami/ruby-minpkg:gem/cgipkg:rpm/almalinux/rubypkg:rpm/almalinux/ruby-default-gemspkg:rpm/almalinux/ruby-develpkg:rpm/almalinux/ruby-docpkg:rpm/almalinux/rubygem-abrtpkg:rpm/almalinux/rubygem-abrt-docpkg:rpm/almalinux/rubygem-bigdecimalpkg:rpm/almalinux/rubygem-bsonpkg:rpm/almalinux/rubygem-bson-docpkg:rpm/almalinux/rubygem-bundlerpkg:rpm/almalinux/rubygem-bundler-docpkg:rpm/almalinux/rubygem-did_you_meanpkg:rpm/almalinux/rubygem-io-consolepkg:rpm/almalinux/rubygem-irbpkg:rpm/almalinux/rubygem-jsonpkg:rpm/almalinux/rubygem-minitestpkg:rpm/almalinux/rubygem-mongopkg:rpm/almalinux/rubygem-mongo-docpkg:rpm/almalinux/rubygem-mysql2pkg:rpm/almalinux/rubygem-mysql2-docpkg:rpm/almalinux/rubygem-net-telnetpkg:rpm/almalinux/rubygem-opensslpkg:rpm/almalinux/rubygem-pgpkg:rpm/almalinux/rubygem-pg-docpkg:rpm/almalinux/rubygem-power_assertpkg:rpm/almalinux/rubygem-psychpkg:rpm/almalinux/rubygem-rakepkg:rpm/almalinux/rubygem-rbspkg:rpm/almalinux/rubygem-rdocpkg:rpm/almalinux/rubygem-rexmlpkg:rpm/almalinux/rubygem-rsspkg:rpm/almalinux/rubygemspkg:rpm/almalinux/rubygems-develpkg:rpm/almalinux/rubygem-test-unitpkg:rpm/almalinux/rubygem-typeprofpkg:rpm/almalinux/rubygem-xmlrpcpkg:rpm/almalinux/ruby-irbpkg:rpm/almalinux/ruby-libspkg:rpm/opensuse/ruby2.5&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/ruby2.5&distro=openSUSE%20Leap%2015.4pkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP3pkg:rpm/suse/ruby2.5&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP4
< 2.6.9+ 44 more
- (no CPE)range: < 2.6.9
- (no CPE)range: < 2.6.9
- (no CPE)range: >= 0.3.0, < 0.3.1
- (no CPE)range: < 2.6.9-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 2.7.6-138.module_el8.6.0+3263+904da987
- (no CPE)range: < 2.6.9-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 2.6.9-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 0.3.0-4.module_el8.5.0+259+8cec6917
- (no CPE)range: < 0.3.0-4.module_el8.5.0+259+8cec6917
- (no CPE)range: < 1.4.1-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 4.5.0-1.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 4.5.0-1.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 1.17.2-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 1.16.1-4.module_el8.5.0+2625+ec418553
- (no CPE)range: < 1.3.0-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 0.4.7-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 1.0.0-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 2.1.0-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 5.11.3-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 2.8.0-1.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 2.8.0-1.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 0.5.2-1.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 0.5.2-1.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 0.2.0-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 2.1.2-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 1.1.4-1.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 1.1.4-1.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 1.1.3-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 3.1.0-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 12.3.3-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 1.4.0-141.module_el8.6.0+3263+41cde0c0
- (no CPE)range: < 6.1.2.1-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 3.2.5-141.module_el8.6.0+3263+41cde0c0
- (no CPE)range: < 0.2.9-141.module_el8.6.0+3263+41cde0c0
- (no CPE)range: < 3.0.3.1-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 3.0.3.1-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 3.2.9-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 0.15.2-141.module_el8.6.0+3263+41cde0c0
- (no CPE)range: < 0.3.0-108.module_el8.5.0+250+ba22dbf7
- (no CPE)range: < 2.5.9-110.module_el8.6.0+3074+4b08f9d4
- (no CPE)range: < 2.6.9-108.module_el8.5.0+2623+08a8ba32
- (no CPE)range: < 2.5.9-150000.4.26.1
- (no CPE)range: < 2.5.9-150000.4.26.1
- (no CPE)range: < 2.5.9-150000.4.26.1
- (no CPE)range: < 2.5.9-150000.4.26.1
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
15- github.com/advisories/GHSA-4vf4-qmvg-mh7hghsaADVISORY
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN/mitrevendor-advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF/mitrevendor-advisory
- nvd.nist.gov/vuln/detail/CVE-2021-41819ghsaADVISORY
- security.gentoo.org/glsa/202401-27ghsavendor-advisoryWEB
- github.com/rubysec/ruby-advisory-db/blob/master/gems/cgi/CVE-2021-41819.ymlghsaWEB
- hackerone.com/reports/910552ghsaWEB
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWNghsaWEB
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZFghsaWEB
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWNghsaWEB
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZFghsaWEB
- security.netapp.com/advisory/ntap-20220121-0003ghsaWEB
- www.ruby-lang.org/en/news/2021/11/24/cookie-prefix-spoofing-in-cgi-cookie-parse-cve-2021-41819ghsaWEB
- security.netapp.com/advisory/ntap-20220121-0003/mitre
- www.ruby-lang.org/en/news/2021/11/24/cookie-prefix-spoofing-in-cgi-cookie-parse-cve-2021-41819/mitre
News mentions
0No linked articles in our index yet.