# CVE-2024-34343: Cross-site Scripting (XSS) in navigateTo if used after SSR in nuxt

> Attackers can execute arbitrary JavaScript via crafted URLs in Nuxt applications after Server-Side Rendering due to flawed protocol validation.

- **Severity:** Medium 6.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 5 Aug 2024
- **Updated:** 8 Aug 2024
- **Also known as:** CLSA-2026-1775781170, CLSA-2026-1775781171, CLSA-2026-1775781180, GHSA-vf6r-87q4-2vjf

## What is CVE-2024-34343?

CVE-2024-34343 is a medium-severity cross-site scripting vulnerability in nuxt, published on 5 Aug 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

Nuxt is a free and open-source framework to create full-stack web applications and websites with Vue.js. The `navigateTo` function attempts to blockthe `javascript:` protocol, but does not correctly use API's provided by `unjs/ufo`. This library also contains parsing discrepancies.  The function first tests to see if the specified URL has a protocol. This uses the unjs/ufo package for URL parsing. This function works effectively, and returns true for a javascript: protocol. After this, the URL is parsed using the parseURL function. This function will refuse to parse poorly formatted URLs. Parsing javascript:alert(1) returns null/"" for all values. Next, the protocol of the URL is then checked using the isScriptProtocol function. This function simply checks the input against a list of protocols, and does not perform any parsing. The combination of refusing to parse poorly formatted URLs, and not performing additional parsing means that script checks fail as no protocol can be found. Even if a protocol was identified, whitespace is not stripped in the parseURL implementation, bypassing the isScriptProtocol checks. Certain special protocols are identified at the top of parseURL. Inserting a newline or tab into this sequence will block the special protocol check, and bypass the latter checks. This ONLY has impact after SSR has occured, the `javascript:` protocol within a location header does not trigger XSS. This issue has been addressed in release version 3.12.4 and all users are advised to upgrade. There are no known workarounds for this vulnerability.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2024-34343?

2 open source packages ship an affected version, including nuxt. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `nuxt` | npm | All versions | 3.12.4 |
| `nuxt` | npm | All versions | 3.12.4 |

Products: Nuxt Nuxt.

## How do I fix CVE-2024-34343?

Upgrade nuxt to 3.12.4 or later.

## Is CVE-2024-34343 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-34343 exists.

## Other vulnerabilities in nuxt

- [CVE-2026-53721](https://insights.sbomify.com/CVE-2026-53721/): Nuxt: Route-rule middleware bypass via case-sensitivity mismatch between vue-router and the routeRules matcher (high 8.8)
- [CVE-2024-23657](https://insights.sbomify.com/CVE-2024-23657/): Path Traversal: '../filedir' in Nuxt Devtools (high 8.8)
- [CVE-2024-34344](https://insights.sbomify.com/CVE-2024-34344/): Remote code execution via the browser when running the test locally in nuxt (high 8.8)
- [CVE-2024-42352](https://insights.sbomify.com/CVE-2024-42352/): Server-Side Request Forgery (SSRF) in nuxt-icon (high 8.6)
- [CVE-2023-3224](https://insights.sbomify.com/CVE-2023-3224/): Code Injection in nuxt/nuxt (high 8.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-34343 and fix it if it is affected.

What it is: CVE-2024-34343 is a medium-severity cross-site scripting vulnerability in nuxt, published on 5 Aug 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-34343 exists.

Affected packages and fixed versions:
- nuxt (npm): affected all versions; fixed in 3.12.4
- nuxt (npm): affected all versions; fixed in 3.12.4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-34343/ (Markdown: https://insights.sbomify.com/CVE-2024-34343/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-34343
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-34343
- OSV: https://osv.dev/vulnerability/CVE-2024-34343

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-34343/
Summaries are generated and may contain mistakes; the official description above is the record.
