CVE-2023-38704 is a high-severity (CVSS 8.1) Improper Input Validation vulnerability in import-in-the-middle. A fix is available for import-in-the-middle — see the affected versions and patch details below.
import-in-the-middle allows unsanitized user controlled input in module generation
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for CVE-2023-38704.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
import-in-the-middlenpmDescription
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-middleand support for EcmaScript Modules is not needed, ensure that none of the following options are set (either via command-line or theNODE_OPTIONSenvironment 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]
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | import-in-the-middle | all versions | 1.4.2npm install import-in-the-middle@1.4.2 |
Affected Products
import-in-the-middledatadoghqDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for import-in-the-middle, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update import-in-the-middle to 1.4.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2023-38704 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Frequently Asked Questions
Is CVE-2023-38704 in your dependencies?
Find it across npm, including transitive dependencies.