CVE-2023-38704
JSON

8.1high

import-in-the-middle allows unsanitized user controlled input in module generation

Severity
8.1high CVSS:3.1 by GitHub_M
Exploit likelihood
1.00% (higher than 63% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-5r27-rw8r-7967

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.

Affected

Product or packageVersionsReported by
DataDog import-in-the-middle< 1.4.2CVE List
import-in-the-middle (npm)before 1.4.2GitHub Advisory Database
datadoghq import-in-the-middlebefore 1.4.2NVD

All scores

GitHub_M8.1high CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
GitHub8.1high CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-20

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database
Impact

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. It allows for remote code execution in cases where an application passes user-supplied input directly to an import() function.

Patches

This vulnerability has been patched in import-in-the-middle version 1.4.2

Workarounds
  • Do not pass any user-supplied input to import(). Instead, verify it against a set of allowed values.
  • If using import-in-the-middle and support for EcmaScript Modules is not needed, ensure that none of the following options are set (either via command-line or the NODE_OPTIONS environment variable):
--loader=import-in-the-middle/hook.mjs
--loader import-in-the-middle/hook.mjs
References

If you have any questions or comments about this advisory, email us at security@datadoghq.com

References

Sources

SourceRecordLicence
CVE ListCVE-2023-38704 changed 2024-10-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-5r27-rw8r-7967 changed 2026-09-10CC-BY-4.0
NVDCVE-2023-38704 changed 2026-06-17Public domain