Moment.js saw a new release with version 2.28.0 on September 13, 2020, following version 2.27.0 released on June 18, 2020 which includes key updates and refinements. Both versions maintain the core functionality for parsing, validating, manipulating, and displaying dates in JavaScript, essential for developers needing reliable date and time handling.
Examining the devDependencies, a primary difference is the specific versioning of some build and testing tools. Most notably, rollup and prettier are specified as "latest" in v2.27.0, while v2.28.0 pins prettier to version 2.0.5 and specifies rollup as 2.17.1, indicating a decision to lock down these tools for build stability or to avoid breaking changes introduced in later versions. This targeted versioning can be crucial for ensuring consistent builds and preventing unexpected errors during development or deployment.
Another significant update is in uglify-js, where specific versions are not specified in v2.27.0 and v2.28.0, but their existence as devDependencies ensures optimized JavaScript code. The dist object, which contains package distribution metadata, shows that v2.28.0 has a slightly larger unpacked size (4118614 bytes) compared to v2.27.0 (4118073 bytes). This minor increase likely reflects internal adjustments, bug fixes or feature enhancements. Developers should always consult the official changelog for a granular view of changes affecting their application.
All the vulnerabilities related to the version 2.28.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.