CVE-2021-41819: Cookie Prefix Spoofing in CGI :Cookie.parse Vulnerability

HIGH
Advisory Identifier: GHSA-4vf4-qmvg-mh7h
CVSS 7.5
CWE-565
Published
Advisory Summary

CVE-2021-41819 is a HIGH (CVSS 7.5) :cookie.parse vulnerability (CWE-565: Reliance on Cookies without Validation and Integrity Checking) affecting Cookie Prefix Spoofing in CGI libraries in the RubyGems ecosystem. The issue involves :cookie.parse. Remediation is available by upgrading affected packages to version 0.3.1, 0.2.1, 0.1.0.1.

CVE-2021-41819 at a Glance

CVE Identifier CVE-2021-41819
GHSA Identifier GHSA-4vf4-qmvg-mh7h
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-565: Reliance on Cookies without Validation and Integrity Checking
Affected Product Cookie Prefix Spoofing in CGI
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2021-41819

To remediate this vulnerability, upgrade all affected Cookie Prefix Spoofing in CGI dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

cgi fixed: 0.3.1
Upgrade cgi to 0.3.1
cgi fixed: 0.2.1
Upgrade cgi to 0.2.1
cgi fixed: 0.1.0.1
Upgrade cgi to 0.1.0.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for cgi

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-41819, inspect your project dependencies for Cookie Prefix Spoofing in CGI:

inspect dependencies for cgi

Analyze the terminal output to locate any version of Cookie Prefix Spoofing in CGI in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-565: Reliance on Cookies without Validation and Integrity Checking, where the product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user. In Cookie Prefix Spoofing in CGI, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

CGI::Cookie.parse in Ruby through 2.6.8 mishandles security prefixes in cookie names. This also affects the CGI gem prior to versions 0.3.1, 0.2.1, 0.1.1, and 0.1.0.1 for Ruby.

CVE-2021-41819 Affected Cookie Prefix Spoofing in CGI Versions

3 component(s)
Fixed Versions:
0.3.10.2.10.1.0.1
Product / Package Ecosystem Affected Versions Fixed Version
cgi
RubyGems
≥ 0.3.0
< 0.3.1
All 1 versions
0.3.0
0.3.1
cgi
RubyGems
≥ 0.2.0
< 0.2.1
All 1 versions
0.2.0
0.2.1
cgi
RubyGems
< 0.1.0.1
0.1.0.1

References

Frequently Asked Questions

What is CVE-2021-41819?
CVE-2021-41819 is a security vulnerability in Cookie Prefix Spoofing in CGI involving :Cookie.parse under CWE-565: Reliance on Cookies without Validation and Integrity Checking.
Which Cookie Prefix Spoofing in CGI versions are affected?
Affected versions include releases prior to 0.3.1, 0.2.1, 0.1.0.1 across affected packages: cgi.
What version fixes CVE-2021-41819?
Upgrading to 0.3.1, 0.2.1, 0.1.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cgi affected?
Yes, cgi is affected in releases prior to 0.3.1, 0.2.1, 0.1.0.1. Upgrade your dependency to 0.3.1, 0.2.1, 0.1.0.1 or later.
What is the CVSS score of CVE-2021-41819?
CVE-2021-41819 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2021-41819?
CVE-2021-41819 is classified under CWE-565: Reliance on Cookies without Validation and Integrity Checking (The product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user.).
How can I check RubyGems dependencies for CVE-2021-41819?
Run the dependency tree command: 'inspect dependencies for cgi'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4vf4-qmvg-mh7h",
  "modified" : "2023-08-29T16:46:42Z",
  "published" : "2022-01-21T23:22:17Z",
  "aliases" : [ "CVE-2021-41819" ],
  "summary" : "Cookie Prefix Spoofing in CGI::Cookie.parse",
  "details" : "CGI::Cookie.parse in Ruby through 2.6.8 mishandles security prefixes in cookie names. This also affects the CGI gem prior to versions 0.3.1, 0.2.1, 0.1.1, and 0.1.0.1 for Ruby.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "cgi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.3.0"
      }, {
        "fixed" : "0.3.1"
      } ]
    } ],
    "versions" : [ "0.3.0" ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "cgi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.2.0"
      }, {
        "fixed" : "0.2.1"
      } ]
    } ],
    "versions" : [ "0.2.0" ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "cgi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.1.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-41819"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/910552"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ruby/cgi"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/cgi/CVE-2021-41819.yml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202401-27"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20220121-0003"
  }, {
    "type" : "WEB",
    "url" : "https://www.ruby-lang.org/en/news/2021/11/24/cookie-prefix-spoofing-in-cgi-cookie-parse-cve-2021-41819"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-565" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-13T18:53:26Z",
    "nvd_published_at" : "2022-01-01T06:15:00Z"
  }
}