NodeJS/moment/2.22.2


Parse, validate, manipulate, and display dates

https://www.npmjs.com/package/moment
MIT

2 Security Vulnerabilities

Path Traversal: 'dir/../../filename' in moment.locale

Published date: 2022-04-04T21:25:48Z
CVE: CVE-2022-24785
Links:

Impact

This vulnerability impacts npm (server) users of moment.js, especially if user provided locale string, eg fr is directly used to switch moment locale.

Patches

This problem is patched in 2.29.2, and the patch can be applied to all affected versions (from 1.0.1 up until 2.29.1, inclusive).

Workarounds

Sanitize user-provided locale name before passing it to moment.js.

References

Are there any links users can visit to find out more?

For more information

If you have any questions or comments about this advisory: * Open an issue in moment repo

Affected versions: ["1.0.0", "1.0.1", "1.1.0", "1.1.1", "1.2.0", "1.3.0", "1.4.0", "1.5.0", "1.5.1", "1.6.0", "1.6.1", "1.6.2", "1.7.0", "1.7.1", "1.7.2", "2.0.0", "2.1.0", "2.2.1", "2.3.0", "2.3.1", "2.4.0", "2.5.0", "2.5.1", "2.6.0", "2.7.0", "2.8.1", "2.8.2", "2.8.3", "2.8.4", "2.9.0", "2.10.2", "2.10.3", "2.10.5", "2.10.6", "2.11.0", "2.11.1", "2.11.2", "2.12.0", "2.13.0", "2.14.0", "2.14.1", "2.15.0", "2.15.1", "2.15.2", "2.16.0", "2.17.0", "2.17.1", "2.18.0", "2.18.1", "2.19.0", "2.19.1", "2.19.2", "2.19.3", "2.19.4", "2.20.0", "2.20.1", "2.21.0", "2.22.0", "2.22.1", "2.22.2", "2.23.0", "2.24.0", "2.25.0", "2.25.1", "2.25.2", "2.25.3", "2.26.0", "2.27.0", "2.28.0", "2.29.0", "2.29.1"]
Secure versions: [2.29.4, 2.30.0, 2.30.1]
Recommendation: Update to version 2.30.1.

Moment.js vulnerable to Inefficient Regular Expression Complexity

Published date: 2022-07-06T18:38:49Z
CVE: CVE-2022-31129
Links:

Impact

  • using string-to-date parsing in moment (more specifically rfc2822 parsing, which is tried by default) has quadratic (N^2) complexity on specific inputs
  • noticeable slowdown is observed with inputs above 10k characters
  • users who pass user-provided strings without sanity length checks to moment constructor are vulnerable to (Re)DoS attacks

Patches

The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking.

Workarounds

In general, given the proliferation of ReDoS attacks, it makes sense to limit the length of the user input to something sane, like 200 characters or less. I haven't seen legitimate cases of date-time strings longer than that, so all moment users who do pass a user-originating string to constructor are encouraged to apply such a rudimentary filter, that would help with this but also most future ReDoS vulnerabilities.

References

There is an excellent writeup of the issue here: https://github.com/moment/moment/pull/6015#issuecomment-1152961973=

Details

The issue is rooted in the code that removes legacy comments (stuff inside parenthesis) from strings during rfc2822 parsing. moment("(".repeat(500000)) will take a few minutes to process, which is unacceptable.

Affected versions: ["2.18.0", "2.18.1", "2.19.0", "2.19.1", "2.19.2", "2.19.3", "2.19.4", "2.20.0", "2.20.1", "2.21.0", "2.22.0", "2.22.1", "2.22.2", "2.23.0", "2.24.0", "2.25.0", "2.25.1", "2.25.2", "2.25.3", "2.26.0", "2.27.0", "2.28.0", "2.29.0", "2.29.1", "2.29.2", "2.29.3"]
Secure versions: [2.29.4, 2.30.0, 2.30.1]
Recommendation: Update to version 2.30.1.

76 Other Versions

Version License Security Released
2.30.1 MIT 2023-12-27 - 10:38 11 months
2.30.0 MIT 2023-12-26 - 19:36 11 months
2.29.4 MIT 2022-07-06 - 16:01 over 2 years
2.29.3 MIT 1 2022-04-17 - 18:27 over 2 years
2.29.2 MIT 1 2022-04-03 - 13:18 over 2 years
2.29.1 MIT 2 2020-10-06 - 11:21 about 4 years
2.29.0 MIT 2 2020-09-22 - 08:31 about 4 years
2.28.0 MIT 2 2020-09-13 - 11:27 about 4 years
2.27.0 MIT 2 2020-06-18 - 22:00 over 4 years
2.26.0 MIT 2 2020-05-20 - 06:46 over 4 years
2.25.3 MIT 2 2020-05-04 - 15:13 over 4 years
2.25.2 MIT 2 2020-05-04 - 12:29 over 4 years
2.25.1 MIT 2 2020-05-01 - 18:51 over 4 years
2.25.0 MIT 2 2020-05-01 - 01:27 over 4 years
2.24.0 MIT 2 2019-01-21 - 21:10 almost 6 years
2.23.0 MIT 2 2018-12-13 - 06:49 almost 6 years
2.22.2 MIT 2 2018-06-01 - 06:58 over 6 years
2.22.1 MIT 2 2018-04-15 - 06:06 over 6 years
2.22.0 MIT 2 2018-03-30 - 22:06 over 6 years
2.21.0 MIT 2 2018-03-02 - 20:41 over 6 years
2.20.1 MIT 2 2017-12-19 - 04:44 almost 7 years
2.20.0 MIT 2 2017-12-17 - 01:15 almost 7 years
2.19.4 MIT 2 2017-12-11 - 01:11 almost 7 years
2.19.3 MIT 2 2017-11-29 - 16:28 almost 7 years
2.19.2 MIT 3 2017-11-11 - 20:34 about 7 years
2.19.1 MIT 3 2017-10-11 - 21:02 about 7 years
2.19.0 MIT 3 2017-10-10 - 09:40 about 7 years
2.18.1 MIT 3 2017-03-21 - 22:58 over 7 years
2.18.0 MIT 3 2017-03-18 - 21:14 over 7 years
2.17.1 MIT 2 2016-12-04 - 05:48 almost 8 years
2.17.0 MIT 2 2016-11-22 - 13:48 almost 8 years
2.16.0 MIT 2 2016-11-10 - 06:54 about 8 years
2.15.2 MIT 2 2016-10-24 - 06:49 about 8 years
2.15.1 MIT 2 2016-09-21 - 03:39 about 8 years
2.15.0 MIT 2 2016-09-12 - 09:27 about 8 years
2.14.1 MIT 2 2016-07-04 - 06:44 over 8 years
2.14.0 MIT 2 2016-07-04 - 05:11 over 8 years
2.13.0 MIT 2 2016-04-18 - 07:41 over 8 years
2.12.0 MIT 2 2016-03-07 - 09:23 over 8 years
2.11.2 MIT 2 2016-02-03 - 22:47 almost 9 years
2.11.1 MIT 5 2016-01-09 - 13:17 almost 9 years
2.11.0 MIT 5 2016-01-02 - 23:38 almost 9 years
2.10.6 MIT 5 2015-07-28 - 04:45 over 9 years
2.10.5 MIT 5 2015-07-26 - 09:33 over 9 years
2.10.3 MIT 5 2015-05-13 - 07:54 over 9 years
2.10.2 MIT 5 2015-04-09 - 06:39 over 9 years
2.9.0 MIT 5 2015-01-08 - 15:01 almost 10 years
2.8.4 MIT 5 2014-11-19 - 04:47 almost 10 years
2.8.3 MIT 5 2014-09-05 - 08:06 about 10 years
2.8.2 MIT 5 2014-08-22 - 13:55 about 10 years
2.8.1 MIT 5 2014-08-01 - 17:21 over 10 years
2.7.0 MIT 5 2014-06-12 - 07:05 over 10 years
2.6.0 MIT 5 2014-04-12 - 16:39 over 10 years
2.5.1 MIT 5 2014-01-22 - 09:28 almost 11 years
2.5.0 MIT 5 2013-12-23 - 21:09 almost 11 years
2.4.0 MIT 5 2013-10-27 - 02:26 about 11 years
2.3.1 MIT 5 2013-10-09 - 02:38 about 11 years
2.3.0 MIT 5 2013-10-07 - 08:30 about 11 years
2.2.1 MIT 5 2013-09-12 - 08:39 about 11 years
2.1.0 MIT 5 2013-07-07 - 20:33 over 11 years
2.0.0 MIT 5 2013-02-08 - 19:13 almost 12 years
1.7.2 MIT 5 2012-10-02 - 17:17 about 12 years
1.7.1 MIT 5 2012-10-01 - 17:33 about 12 years
1.7.0 MIT 5 2012-07-25 - 19:10 over 12 years
1.6.2 MIT 5 2012-05-04 - 17:20 over 12 years
1.6.1 MIT 5 2012-04-26 - 22:30 over 12 years
1.6.0 MIT 5 2012-04-26 - 16:50 over 12 years
1.5.1 MIT 5 2012-04-06 - 02:08 over 12 years
1.5.0 MIT 5 2012-03-19 - 19:44 over 12 years
1.4.0 MIT 5 2012-02-03 - 19:16 almost 13 years
1.3.0 MIT 5 2012-01-05 - 17:51 almost 13 years
1.2.0 MIT 5 2011-12-06 - 18:33 almost 13 years
1.1.1 MIT 5 2011-11-11 - 19:16 about 13 years
1.1.0 MIT 5 2011-10-27 - 23:21 about 13 years
1.0.1 MIT 5 2011-12-06 - 18:33 almost 13 years
1.0.0 MIT 5 2011-12-06 - 18:33 almost 13 years