CVE-2024-34344: Nuxt Remote Code Execution Vulnerability
CRITICALCVE-2024-34344 is a CRITICAL (CVSS 8.8) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Nuxt libraries in the npm ecosystem. The issue involves nuxt vulnerable to remote code execution via the browser when running the test locally. Remediation is available by upgrading affected packages to version 3.12.4.
CVE-2024-34344 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2024-34344
To remediate this vulnerability, upgrade all affected Nuxt 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 nuxt@3.12.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls nuxt
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-34344, inspect your project dependencies using npm:
npm ls nuxt
Analyze the terminal output to locate any version of Nuxt in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.12.4), your application is affected.
Note: The npm ls nuxt 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Nuxt, 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-2024-34344 Affected Nuxt Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nuxt
|
npm |
≥ 3.4.0
< 3.12.4
|
3.12.4
|
References
Frequently Asked Questions
What is CVE-2024-34344?
Which Nuxt versions are affected?
What version fixes CVE-2024-34344?
Is nuxt affected?
What is the CVSS score of CVE-2024-34344?
What CWE is associated with CVE-2024-34344?
How can I check npm dependencies for CVE-2024-34344?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-v784-fjjh-f8r4",
"modified" : "2024-11-18T16:27:00Z",
"published" : "2024-08-05T19:49:45Z",
"aliases" : [ "CVE-2024-34344" ],
"summary" : "Nuxt vulnerable to remote code execution via the browser when running the test locally",
"details" : "### Summary\nDue to the insufficient validation of the `path` parameter in the NuxtTestComponentWrapper, an attacker can execute arbitrary JavaScript on the server side, which allows them to execute arbitrary commands.\n\n### Details\nWhile running the test, a special component named `NuxtTestComponentWrapper` is available.\nhttps://github.com/nuxt/nuxt/blob/4779f5906fa4d3c784c2e2d6fe5a5c5f181faaec/packages/nuxt/src/app/components/nuxt-root.vue#L42-L43\n\nThis component loads the specified path as a component and renders it.\n\nhttps://github.com/nuxt/nuxt/blob/4779f5906fa4d3c784c2e2d6fe5a5c5f181faaec/packages/nuxt/src/app/components/test-component-wrapper.ts#L9-L27\n\nThere is a validation for the `path` parameter to check whether the path traversal is performed, but this check is not sufficient.\n\nhttps://github.com/nuxt/nuxt/blob/4779f5906fa4d3c784c2e2d6fe5a5c5f181faaec/packages/nuxt/src/app/components/test-component-wrapper.ts#L15-L19\n\nSince `import(...)` uses `query.path` instead of the normalized `path`, a non-normalized URL can reach the `import(...)` function.\nFor example, passing something like `./components/test` normalizes `path` to `/root/directory/components/test`, but `import(...)` still receives `./components/test`.\n\nBy using this behavior, it's possible to load arbitrary JavaScript by using the path like the following:\n```\ndata:text/javascript;base64,Y29uc29sZS5sb2coMSk\n```\n\nSince `resolve(...)` resolves the filesystem path, not the URI, the above URI is treated as a relative path, but `import(...)` sees it as an absolute URI, and loads it as a JavaScript.\n\n### PoC\n1. Create a nuxt project and run it in the test mode:\n```\nnpx nuxi@latest init test\ncd test\nTEST=true npm run dev\n```\n2. Open the following URL:\n```\nhttp://localhost:3000/__nuxt_component_test__/?path=data%3Atext%2Fjavascript%3Bbase64%2CKGF3YWl0IGltcG9ydCgnZnMnKSkud3JpdGVGaWxlU3luYygnL3RtcC90ZXN0JywgKGF3YWl0IGltcG9ydCgnY2hpbGRfcHJvY2VzcycpKS5zcGF3blN5bmMoIndob2FtaSIpLnN0ZG91dCwgJ3V0Zi04Jyk\n```\n3. Confirm that the output of `whoami` is written to `/tmp/test`\n\nDemonstration video: https://www.youtube.com/watch?v=FI6mN8WbcE4\n\n### Impact\nUsers who open a malicious web page in the browser while running the test locally are affected by this vulnerability, which results in the remote code execution from the malicious web page.\nSince web pages can send requests to arbitrary addresses, a malicious web page can repeatedly try to exploit this vulnerability, which then triggers the exploit when the test server starts.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "nuxt"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.4.0"
}, {
"fixed" : "3.12.4"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nuxt/nuxt/security/advisories/GHSA-v784-fjjh-f8r4"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-34344"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nuxt/nuxt"
}, {
"type" : "WEB",
"url" : "https://github.com/nuxt/nuxt/blob/4779f5906fa4d3c784c2e2d6fe5a5c5f181faaec/packages/nuxt/src/app/components/test-component-wrapper.ts#L15-L19"
}, {
"type" : "WEB",
"url" : "https://github.com/nuxt/nuxt/blob/4779f5906fa4d3c784c2e2d6fe5a5c5f181faaec/packages/nuxt/src/app/components/test-component-wrapper.ts#L9-L27"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-706", "CWE-94" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2024-08-05T19:49:45Z",
"nvd_published_at" : "2024-08-05T21:15:38Z"
}
}