Moment.js saw a minor version bump from 2.22.1 to 2.22.2, representing a focused update to this popular JavaScript date manipulation and formatting library. While the core description remains consistent – parsing, validating, manipulating, and displaying dates – developers should be aware of the subtle changes reflected in this increment. Both versions maintain the same suite of development dependencies, ensuring a consistent build and testing environment. Key tools like grunt, karma, and rollup for building, testing, and bundling are unchanged, suggesting a stability-focused release. The license remains MIT, and the repository details remain pointed at the official GitHub location, showing commitment to open-source principles.
The dist section reveals a slight increase in unpacked size from 2,714,142 bytes (v2.22.1) to 2,714,826 bytes (v2.22.2). This suggests that bug fixes, performance enhancements or minor feature additions are likely the focus of the release. The fileCount remains at 364. Furthermore the release date indicates that version 2.22.2 was released on May 31st approximately one and a half months after the release of version 2.22.1. Users should review the changelog for specific details, but the update likely addresses reported issues. Upgrading is generally recommended to benefit from these improvements.
All the vulnerabilities related to the version 2.22.2 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.