Vulnerabilities in pkg:npm/import-in-the-middle
PACKAGECVE-2023-38704 is a HIGH (CVSS 8.1) import-in-the-middle has unsanitized user controlled vulnerability (CWE-20: Improper Input Validation) affecting Import in the middle libraries in the npm ecosystem. The issue involves import-in-the-middle has unsanitized user controlled input in module generation. Remediation is available by upgrading affected packages to version 1.4.2.
pkg:npm/import-in-the-middle
Vulnerability advisories affecting package pkg:npm/import-in-the-middle. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-5r27-rw8r-7967 | CVE-2023-38704 | HIGH | import-in-the-middle has unsanitized user controlled input in module generation |
CVE-2023-38704 at a Glance
Security Impact
CVSS: 8.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L).
How to Fix CVE-2023-38704
To remediate this vulnerability, upgrade all affected Import in the middle dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install import-in-the-middle@1.4.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls import-in-the-middle
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2023-38704, inspect your project dependencies using npm:
npm ls import-in-the-middle
Analyze the terminal output to locate any version of Import in the middle in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.2), your application is affected.
Note: The npm ls import-in-the-middle command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Import in the middle, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2023-38704 Affected Import in the middle Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
import-in-the-middle
|
npm |
< 1.4.2
|
1.4.2
|
References
Frequently Asked Questions
What is CVE-2023-38704?
Which Import in the middle versions are affected?
What version fixes CVE-2023-38704?
Is import-in-the-middle affected?
What is the CVSS score of CVE-2023-38704?
What CWE is associated with CVE-2023-38704?
How can I check npm dependencies for CVE-2023-38704?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-5r27-rw8r-7967",
"modified" : "2023-08-14T13:14:54Z",
"published" : "2023-08-08T19:26:40Z",
"aliases" : [ "CVE-2023-38704" ],
"summary" : "import-in-the-middle has unsanitized user controlled input in module generation",
"details" : "### Impact\nThe `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.\n\n### Patches\nThis vulnerability has been patched in `import-in-the-middle` version 1.4.2\n\n### Workarounds\n* Do not pass any user-supplied input to `import()`. Instead, verify it against a set of allowed values.\n* 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):\n```\n--loader=import-in-the-middle/hook.mjs\n--loader import-in-the-middle/hook.mjs\n```\n\n### References\nIf you have any questions or comments about this advisory, email us at [security@datadoghq.com](mailto:security@datadoghq.com)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:L/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "import-in-the-middle"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.4.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.4.1"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/DataDog/import-in-the-middle/security/advisories/GHSA-5r27-rw8r-7967"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-38704"
}, {
"type" : "WEB",
"url" : "https://github.com/DataDog/import-in-the-middle/commit/2531cdd9d1d73f9eaa87c16967f60cb276c1971b"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/DataDog/import-in-the-middle"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-20" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2023-08-08T19:26:40Z",
"nvd_published_at" : "2023-08-07T20:15:09Z"
}
}