CVE-2024-34343
JSON

6.3medium

Cross-site Scripting (XSS) in navigateTo if used after SSR in nuxt

Severity
6.3medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.44% (higher than 39% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-vf6r-87q4-2vjf

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.

Affected

Product or packageVersionsReported by
nuxt nuxt< 3.12.4, 3.12.4, before 3.12.4CVE List, NVD
nuxt (npm)before 3.12.4GitHub Advisory Database

All scores

GitHub_M6.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L
GitHub6.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
NVD6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Classification

CWE-79CWE-83

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database
Summary

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.

Details

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.

PoC

POC - https://stackblitz.com/edit/nuxt-xss-navigateto?file=app.vue

Attempt payload X, then attempt payload Y.

Impact

XSS, access to cookies, make requests on user's behalf.

Recommendations

As always with these bugs, the URL constructor provided by the browser is always the safest method of parsing a URL.

Given the cross-platform requirements of nuxt/ufo a more appropriate solution is to make parsing consistent between functions, and to adapt parsing to be more consistent with the WHATWG URL specification.

Note

I've reported this vulnerability here as it is unclear if this is a bug in ufo or a misuse of the ufo library.

This ONLY has impact after SSR has occurred, the javascript: protocol within a location header does not trigger XSS.

NVD (es)

Nuxt es un framework gratuito y de código abierto para crear sitios web y aplicaciones web completos con Vue.js. La función `navigateTo` intenta bloquear el protocolo `javascript:`, pero no utiliza correctamente las API proporcionadas por `unjs/ufo`. Esta biblioteca también contiene discrepancias en el análisis. La función primero prueba para ver si la URL especificada tiene un protocolo. Esto utiliza el paquete unjs/ufo para el análisis de URL. Esta función funciona de manera efectiva y devuelve verdadero para un protocolo javascript:. Después de esto, la URL se analiza utilizando la función parseURL. Esta función se negará a analizar URL mal formateadas. El análisis de javascript:alert(1) devuelve null/"" para todos los valores. A continuación, se verifica el protocolo de la URL utilizando la función isScriptProtocol. Esta función simplemente compara la entrada con una lista de protocolos y no realiza ningún análisis. La combinación de negarse a analizar URL mal formateadas y no realizar análisis adicionales significa que las comprobaciones de secuencias de comandos fallan porque no se puede encontrar ningún protocolo. Incluso si se identificó un protocolo, los espacios en blanco no se eliminan en la implementación de parseURL, evitando las comprobaciones de isScriptProtocol. Ciertos protocolos especiales se identifican en la parte superior de parseURL. Insertar una nueva línea o una pestaña en esta secuencia bloqueará la verificación del protocolo especial y omitirá las últimas comprobaciones. Esto SÓLO tiene impacto después de que se haya producido SSR, el protocolo `javascript:` dentro de un encabezado de ubicación no activa XSS. Este problema se solucionó en la versión 3.12.4 y se recomienda a todos los usuarios que actualicen. No se conocen workarounds para esta vulnerabilidad.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-34343 changed 2024-08-08CVE Terms of Use
GitHub Advisory DatabaseGHSA-vf6r-87q4-2vjf changed 2025-05-15CC-BY-4.0
NVDCVE-2024-34343 changed 2026-06-17Public domain