CVE-2021-41817: High severity ruby vulnerability
A flaw was found in ruby, where the date object was found to be vulnerable to a regular expression denial of service (ReDoS) during the parsing of dates. This flaw allows an attacker to hang a ruby application by providing a specially crafted date string. The highest threat to this vulnerability is system availability.
Other sources
Date.parse in the date gem through 3.2.0 for Ruby allows ReDoS (regular expression Denial of Service) via a long string. The fixed versions are 3.2.1, 3.1.2, 3.0.2, and 2.0.1.
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.
References:
https://github.com/rubysec/ruby-advisory-db/blob/master/gems/date/CVE-2021-41817.yml https://www.ruby-lang.org/en/news/2021/11/15/date-parsing-method-regexp-dos-cve-2021-41817/
— Red Hat
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')
— GitHub
Affected Software
Event History
Parent advisories
This vulnerability appears in the following advisories.
Frequently Asked Questions
What is CVE-2021-41817?
CVE-2021-41817 is a vulnerability in the date parsing method of the Ruby date gem that allows for regular expression Denial of Service (ReDoS) attacks.
What is the severity of CVE-2021-41817?
CVE-2021-41817 has a severity rating of 7.5 (high).
How does CVE-2021-41817 affect Ruby applications?
CVE-2021-41817 allows an attacker to hang a Ruby application by providing a specially crafted date string.
Which versions of the Ruby date gem are affected by CVE-2021-41817?
Versions up to and including 3.2.0 of the Ruby date gem are affected by CVE-2021-41817.
How can I fix CVE-2021-41817?
To fix CVE-2021-41817, update the Ruby date gem to version 3.2.1 or later.