CVE-2023-38704 import-in-the-middle allows unsanitized user controlled input in module generation
Attackers can execute arbitrary code if user input is passed to import() in applications using the import-in-the-middle 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-2023-38704?
CVE-2023-38704 is a high-severity code injection vulnerability in DataDog import-in-the-middle, published on 7 Aug 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
import-in-the-middle is a module loading interceptor specifically for ESM modules. The import-in-the-middle loader works by generating a wrapper module on the fly. The wrapper uses the module specifier to load the original module and add some wrapping code. Prior to version 1.4.2, it allows for remote code execution in cases where an application passes user-supplied input directly to the `import()` function. This vulnerability has been patched in import-in-the-middle version 1.4.2.
Some workarounds are available. Do not pass any user-supplied input to `import()`. Instead, verify it against a set of allowed values. If using import-in-the-middle, directly or indirectly, and support for EcmaScript Modules is not needed, ensure that no options are set, either via command-line or the `NODE_OPTIONS` environment variable, that would enable loader hooks.
Weakness: CWE-20
Which versions are affected by CVE-2023-38704?
2 open source packages ship an affected version, including import-in-the-middle. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
import-in-the-middle npm | All versions | 1.4.2 |
import-in-the-middle npm | All versions | 1.4.2 |
Products include Datadoghq Import-in-the-Middle.
How do I fix CVE-2023-38704?
Upgrade import-in-the-middle to 1.4.2 or later.
Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.
Is CVE-2023-38704 being exploited?
There is no known exploitation of CVE-2023-38704 in the wild and no public exploit code.
Sources
Also known as GHSA-5r27-rw8r-7967, ROOT-APP-NPM-CVE-2023-38704.