Moment.js saw a significant update between version 2.24.0 and 2.25.0, impacting developers using this popular date manipulation library. While both versions share the core functionality of parsing, validating, manipulating, and displaying dates, several changes occurred under the hood. Version 2.25.0 boasts a larger unpacked size of 3,484,978 bytes compared to 2.24.0's 2,791,997 bytes, suggesting increased functionality or potentially larger dependencies. The file count also increased from 372 to 391.
Delving into the devDependencies, numerous upgrades are apparent. Most notably, Typescript jumps from "^1.8.10" to "^3.1.6" (under alias typescript3), potentially opening support for newer Typescript features and syntax, though requiring project updates if developers haven't upgraded their toolchain. The older version showed qunit as a dev dependency while the newer doesn't show it explicitly which might suggest testing framework updates and improved testing infrastructure. Several other development dependencies shifted to "latest" versions, indicating an active effort to keep the development environment current. Dependencies like "grunt-jscs" and "grunt-contrib-jshint" were removed and replaced with tools like "eslint" and "prettier" suggesting a move towards more modern linting and formatting tools. Both versions maintain the MIT license, ensuring continued open-source use and contribution. Both releases were authored by Iskren Ivov Chernev. These updates collectively indicate a focus on modernizing the development tooling and potentially enhancing the library's internal architecture, leading to a more robust experience for developers.
All the vulnerabilities related to the version 2.25.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.