CVE-2022-31129 Inefficient Regular Expression Complexity in moment

High 7.5 Published Updated

Attackers can cause denial of service via ReDoS by providing long strings to the moment.js date parsing function.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2022-31129?

CVE-2022-31129 is a high-severity denial of service vulnerability in Debian Debian Linux, published on 6 Jul 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

moment is a JavaScript date library for parsing, validating, manipulating, and formatting dates. Affected versions of moment were found to use an inefficient parsing algorithm. Specifically using string-to-date parsing in moment (more specifically rfc2822 parsing, which is tried by default) has quadratic (N^2) complexity on specific inputs. Users may notice a noticeable slowdown is observed with inputs above 10k characters. Users who pass user-provided strings without sanity length checks to moment constructor are vulnerable to (Re)DoS attacks. The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking. Users are advised to upgrade. Users unable to upgrade should consider limiting date lengths accepted from user input.

Weakness: CWE-1333, CWE-400

Which versions are affected by CVE-2022-31129?

4 open source packages ship an affected version, including Moment.js and moment. It affects 3 products.

PackageAffectedFixed in
Moment.js NuGetFrom 2.18.02.29.4
Moment.js NuGetFrom 2.18.02.29.4
moment npmFrom 2.18.02.29.4
moment npmFrom 2.18.02.29.4
Linux distribution packages (2)
cockpit-ovirt Red Hat:rhev_hypervisor:4.4::el8All versions0:0.16.2-1.el8ev
cockpit-ovirt-dashboard Red Hat:rhev_hypervisor:4.4::el8All versions0:0.16.2-1.el8ev

Products include Debian Debian Linux, Fedoraproject Fedora, Momentjs Moment.

How do I fix CVE-2022-31129?

Upgrade Moment.js to 2.29.4 or later.

Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.

Is CVE-2022-31129 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-31129 exists.

All Debian Debian Linux vulnerabilities

Sources

Also known as DEBIAN-CVE-2022-31129, GHSA-wc69-rhjr-hc9g, RHSA-2022:6392, ROOT-APP-NPM-CVE-2022-31129, UBUNTU-CVE-2022-31129.

Is CVE-2022-31129 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free