Moment.js, a widely used JavaScript library for date and time manipulation and formatting, offers two closely related versions, 2.29.3 and 2.29.2. Both share the core functionality for parsing, validating, manipulating, and displaying dates in JavaScript, making them essential tools for developers dealing with time-related tasks. The core features remain consistent: a comprehensive suite of methods for date arithmetic, formatting according to various patterns, and time zone handling.
Examining the metadata, the key differences lie in their release dates and unpacked size. Version 2.29.3 was released on April 17, 2022, while version 2.29.2 was released on April 3, 2022. This indicates that 2.29.3 likely includes bug fixes or minor improvements implemented after the release of 2.29.2. The unpacked size is also slightly different, with 2.29.3 being marginally larger (4,229,297 bytes vs. 4,228,909 bytes), also suggesting internal changes, fixes, or added functionalities.
For developers, choosing between these versions hinges on the need for the latest bug fixes. While the core API remains stable, opting for 2.29.3 ensures access to the most recent improvements, leading to more reliable date handling. While many development dependencies are the same, it is important to update the package. If staying on 2.29.2 the improvements maybe not worth the risks of breaking changes. Developers should consider upgrading accordingly.
All the vulnerabilities related to the version 2.29.3 of the package
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.