CVE-2024-21541 dom-iterator code execution vulnerability

Medium 6.9 Published Updated

An attacker can execute arbitrary code by exploiting insufficient input sanitization in the Function constructor within the dom-iterator library.

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

What is CVE-2024-21541?

CVE-2024-21541 is a medium-severity code injection vulnerability in dom-iterator, published on 13 Nov 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Versions of the package dom-iterator before 1.0.1 are vulnerable to Arbitrary Code Execution due to use of the Function constructor without complete input sanitization. Function generates a new function body and thus care must be given to ensure that the inputs to Function are not attacker-controlled. The risks involved are similar to that of allowing attacker-controlled input to reach eval.

Weakness: CWE-94

Which versions are affected by CVE-2024-21541?

2 open source packages ship an affected version, including dom-iterator. It affects 1 product.

PackageAffectedFixed in
dom-iterator npmAll versions1.0.1
dom-iterator npmAll versions1.0.1

Products include Matthewmueller Dom-Iterator.

How do I fix CVE-2024-21541?

Upgrade dom-iterator to 1.0.1 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2024-21541 being exploited?

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

Sources

Also known as GHSA-jrvm-mcxc-mf6m.

Is CVE-2024-21541 in your software?

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

Check your SBOMs for free