Regular expression denial of service vulnerability (ReDoS) in date
Published 16 Nov 2021 · Updated 27 Jan 2025
Is your project on an affected date?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- >=3.2.0 <3.2.1
- Fixed in
- 3.2.1
bundle update --conservative date # Gemfile: '>= 3.2.1'- Affected
- >=3.1.0 <3.1.2
- Fixed in
- 3.1.2
bundle update --conservative date # Gemfile: '>= 3.1.2'- Affected
- >=3.0.0 <3.0.2
- Fixed in
- 3.0.2
bundle update --conservative date # Gemfile: '>= 3.0.2'- Affected
- <2.0.1
- Fixed in
- 2.0.1
bundle update --conservative date # Gemfile: '>= 2.0.1'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.
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
Date.strptime('2001-02-20', '%Y-%m-%d')Is GHSA-qg54-694p-wgpp in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected date, and gives you the command that fixes it.
References
- Advisorynvd.nist.gov/vuln/detail/CVE-2021-41817
- Linkgithub.com/ruby/date/commit/3959accef8da5c128f8a8e2fd54e932a4fb253b0
- Linkhackerone.com/reports/1254844
- Packagegithub.com/ruby/date
- Linkgithub.com/rubysec/ruby-advisory-db/blob/master/gems/date/CVE-2021-41817.yml
- Linklists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN
- Linklists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IUXQCH6FRKANCVZO2Q7D2SQX33FP3KWN
- Linklists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UTOJGS5IEFDK3UOO7IY4OTTFGHGLSWZF
- Linksecurity.gentoo.org/glsa/202401-27
- Linkwww.ruby-lang.org/en/news/2021/11/15/date-parsing-method-regexp-dos-cve-2021-41817
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.