Every CVE Search/ Get API key

CVE-2023-38704

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

8.1 HighFix available

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.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
High
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
High
Integrity
Low
Availability
Low

Exploit likelihood

1.00%Up 0.9 points since Aug 8, 2023
90%50%10%1%

What each source reports

CVE List Score used 8.1

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

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.

Record
CVE-2023-38704
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
Weakness
CWE-20
Updated
2026-11-02
EUVDEUVD-2023-2217 8.1

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.

Record
EUVD-2023-2217
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
Updated
2026-11-03
GitHub AdvisoriesGHSA-5r27-rw8r-7967 8.1

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

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 [email protected]

Record
GHSA-5r27-rw8r-7967
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
Weakness
CWE-20
Updated
2026-11-02
NVD 8.1

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.

Record
CVE-2023-38704
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
CVSS 3.1
9.8 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Weakness
CWE-20
Updated
2026-11-02
OSV 8.1

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

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.

Record
CVE-2023-38704
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
Weakness
CWE-20
Updated
2026-11-02
OSVGHSA-5r27-rw8r-7967 8.1

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

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 [email protected]

Record
GHSA-5r27-rw8r-7967
CVSS 3.1
8.1 HighCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L
Weakness
CWE-20
Updated
2026-11-02
OSVROOT-APP-NPM-CVE-2023-38704 No score

CVE-2023-38704 in import-in-the-middle - Patched by Root

Root has patched CVE-2023-38704 in the import-in-the-middle package for Root:npm. Multiple fixed versions available.

Record
ROOT-APP-NPM-CVE-2023-38704
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
import-in-the-middle
npm
through 1.4.1
1.4.2
import-in-the-middle
npm
before 1.4.2
1.4.2
import-in-the-middle
Root:npm
before 1.3.4-aikido.1
1.3.4-aikido.1
@rootio/import-in-the-middle
Root:npm
before 1.3.4-root.io.1
1.3.4-root.io.1

History

History
RecordedChangedSources
aliases, publishedEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2023-38704 is a high vulnerability (CVSS 8.1) in Datadog Import-in-the-middle, published August 7, 2023. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 1.00%, the 62nd percentile. Fixed in import-in-the-middle 1.4.2.

References

MoveEnter Open