Moment.js saw a jump from version 2.23.0 to 2.24.0, offering developers a refined experience in parsing, validating, manipulating, and displaying dates and times in JavaScript. Both versions maintain the core functionality that has made Moment.js a staple for date handling, including robust localization support, flexible formatting options, and intuitive API for date arithmetic.
However, a detailed look reveals subtle but potentially impactful modifications. The upgrade includes increased fileCountand unpackedSize, implying enhancements and additions to the library's internal structure and potentially new features or expanded localization data. Specifically, 2.24.0 introduces an increased number of files(372) from the older version(366) and a bigger unpacked size(2791997) from (2737053).
Developers considering the upgrade should particularly be aware of any changes related to bug fixes, performance improvements, or the introduction of new date formatting tokens or locale definitions. While the listed devDependencies remain mostly consistent, any changes in the core logic might affect existing applications. Reviewing the official changelog or release notes for Moment.js 2.24.0 is strongly recommended to understand the specifics of these changes and ensure a smooth transition with no breaking changes for existing implementations. These incremental updates are crucial for maintaining application stability and taking advantage of library improvements.
All the vulnerabilities related to the version 2.24.0 of the package
Path Traversal: 'dir/../../filename' in moment.locale
This vulnerability impacts npm (server) users of moment.js, especially if user provided locale string, eg fr
is directly used to switch moment locale.
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).
Sanitize user-provided locale name before passing it to moment.js.
Are there any links users can visit to find out more?
If you have any questions or comments about this advisory:
Moment.js vulnerable to Inefficient Regular Expression Complexity
The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking.
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.
There is an excellent writeup of the issue here: https://github.com/moment/moment/pull/6015#issuecomment-1152961973=
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.