Moment.js version 2.21.0, released on March 2nd, 2018, presents a refined iteration over its predecessor, version 2.20.1, which was launched on December 19th, 2017. Both versions share the same core functionality: parsing, validating, manipulating, and displaying dates and times in JavaScript environments. Developers utilizing Moment.js for date-time management will find the newer version enhanced with potential bug fixes and subtle improvements accumulated over the intervening months.
The development dependencies remain consistent across both releases, indicating no significant shifts in the tooling used to build and test the library. This stable foundation includes familiar tools such as Grunt for task automation, Karma for testing, and Rollup for bundling. The 'nyc' code coverage tool, along with various Grunt plugins for linting, optimization, and other build processes, suggests a strong commitment to code quality and maintainability. This continuity offers developers assurance that upgrading won't introduce compatibility issues stemming from build-time tooling changes.
While the feature set might be largely similar, developers should prioritize upgrading to version 2.21.0 to benefit from the latest refinements and potential security patches. Furthermore, the presence of tools like benchmark hints at ongoing efforts to optimize performance, subtly improving the user experience of applications relying on Moment.js for date-time operations. The consistent licensing under MIT assures developers of the library's free and open-source nature. While the dist section mentions fileCount and unpackedSize only for version 2.21.0, this information is secondary to the core functionality improvement.
All the vulnerabilities related to the version 2.21.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.