Vulnerabilities in pkg:gem/date

PACKAGE
Advisory Identifier: GHSA-qg54-694p-wgpp
Advisory Summary

CVE-2021-41817 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Date libraries in the RubyGems ecosystem. The issue involves regular expression denial of service vulnerability (redos) in date. Remediation is available by upgrading affected packages to version 3.2.1, 3.1.2, 3.0.2, 2.0.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:gem/date

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:gem/date. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-qg54-694p-wgpp CVE-2021-41817 HIGH Regular expression denial of service vulnerability (ReDoS) in date

CVE-2021-41817 at a Glance

CVE Identifier CVE-2021-41817
GHSA Identifier GHSA-qg54-694p-wgpp
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Date
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:N/A:H).

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 None (I:N)
Availability High (A:H)

How to Fix CVE-2021-41817

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

date fixed: 3.2.1
Upgrade date to 3.2.1
date fixed: 3.1.2
Upgrade date to 3.1.2
date fixed: 3.0.2
Upgrade date to 3.0.2
date fixed: 2.0.1
Upgrade date to 2.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 date

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-41817, inspect your project dependencies for Date:

inspect dependencies for date

Analyze the terminal output to locate any version of Date in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.2.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-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Date, 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

Date’s parsing methods including Date.parse are using Regexps internally, some of which are vulnerable against regular expression denial of service. Applications and libraries that apply such methods to untrusted input may be affected. The fix limits the input length up to 128 bytes by default instead of changing the regexps. This is because Date gem uses many Regexps and it is possible that there are still undiscovered vulnerable Regexps. For compatibility, it is allowed to remove the limitation by explicitly passing limit keywords as nil like Date.parse(str, limit: nil), but note that it may take a long time to parse. Please update the date gem to version 3.2.1, 3.1.2, 3.0.2, and 2.0.1, or later. You can use gem update date to update it. If you are using bundler, please add gem "date", ">= 3.2.1" to your Gemfile. If you import `date` from the standard library rather than as a gem you should update your Ruby install to `3.0.3`, `2.7.5`, `2.6.9` or later. Users unable to upgrade may consider using `Date.strptime` instead with a predefined date format ```ruby Date.strptime('2001-02-20', '%Y-%m-%d') ```

CVE-2021-41817 Affected Date Versions

4 component(s)
Fixed Versions:
3.2.13.1.23.0.22.0.1
Product / Package Ecosystem Affected Versions Fixed Version
date
RubyGems
≥ 3.2.0
< 3.2.1
3.2.1
date
RubyGems
≥ 3.1.0
< 3.1.2
3.1.2
date
RubyGems
≥ 3.0.0
< 3.0.2
3.0.2
date
RubyGems
< 2.0.1
2.0.1

References

Frequently Asked Questions

What is CVE-2021-41817?
CVE-2021-41817 is a security vulnerability in Date involving Regular expression denial of service vulnerability (ReDoS) in date under CWE-1333: Inefficient Regular Expression Complexity.
Which Date versions are affected?
Affected versions include releases prior to 3.2.1, 3.1.2, 3.0.2, 2.0.1 across affected packages: date.
What version fixes CVE-2021-41817?
Upgrading to 3.2.1, 3.1.2, 3.0.2, 2.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is date affected?
Yes, date is affected in releases prior to 3.2.1, 3.1.2, 3.0.2, 2.0.1. Upgrade your dependency to 3.2.1, 3.1.2, 3.0.2, 2.0.1 or later.
What is the CVSS score of CVE-2021-41817?
CVE-2021-41817 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:N/A:H.
What CWE is associated with CVE-2021-41817?
CVE-2021-41817 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check RubyGems dependencies for CVE-2021-41817?
Run the dependency tree command: 'inspect dependencies for date'. 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-qg54-694p-wgpp",
  "modified" : "2024-01-24T19:18:37Z",
  "published" : "2021-11-16T00:32:30Z",
  "aliases" : [ "CVE-2021-41817" ],
  "summary" : "Regular expression denial of service vulnerability (ReDoS) in date",
  "details" : "Date’s parsing methods including Date.parse are using Regexps internally, some of which are vulnerable against regular expression denial of service. Applications and libraries that apply such methods to untrusted input may be affected.\n\nThe fix limits the input length up to 128 bytes by default instead of changing the regexps. This is because Date gem uses many Regexps and it is possible that there are still undiscovered vulnerable Regexps. For compatibility, it is allowed to remove the limitation by explicitly passing limit keywords as nil like Date.parse(str, limit: nil), but note that it may take a long time to parse.\n\nPlease update the date gem to version 3.2.1, 3.1.2, 3.0.2, and 2.0.1, or later. You can use gem update date to update it. If you are using bundler, please add gem \"date\", \">= 3.2.1\" to your Gemfile. If you import `date` from the standard library rather than as a gem you should update your Ruby install to `3.0.3`, `2.7.5`, `2.6.9` or later.\n\nUsers unable to upgrade may consider using `Date.strptime` instead with a predefined date format\n```ruby\nDate.strptime('2001-02-20', '%Y-%m-%d')\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "date"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.2.0"
      }, {
        "fixed" : "3.2.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "date"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.1.0"
      }, {
        "fixed" : "3.1.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "date"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.0.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "date"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-41817"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ruby/date/commit/3959accef8da5c128f8a8e2fd54e932a4fb253b0"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/1254844"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ruby/date"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/date/CVE-2021-41817.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://www.ruby-lang.org/en/news/2021/11/15/date-parsing-method-regexp-dos-cve-2021-41817"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-11-16T00:15:43Z",
    "nvd_published_at" : "2022-01-01T05:15:00Z"
  }
}