CVE-2024-45047
JSON

5.4medium

Potential mXSS vulnerability due to improper HTML escaping in svelte

Severity
5.4medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.36% (higher than 32% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-8266-84wp-wv5c

Description

svelte performance oriented web framework. A potential mXSS vulnerability exists in Svelte for versions up to but not including 4.2.19. Svelte improperly escapes HTML on server-side rendering. The assumption is that attributes will always stay as such, but in some situation the final DOM tree rendered on browsers is different from what Svelte expects on server-side rendering. This may be leveraged to perform XSS attacks, and a type of the XSS is known as mXSS (mutation XSS). More specifically, this can occur when injecting malicious content into an attribute within a `noscript` tag. This issue has been addressed in release version 4.2.19. Users are advised to upgrade. There are no known workarounds for this vulnerability.

Affected

Product or packageVersionsReported by
sveltejs svelte< 4.2.19CVE List
svelte sveltebefore 4.2.19CVE List, NVD
svelte (npm)before 4.2.19GitHub Advisory Database

All scores

GitHub_M5.4medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
GitHub5.4medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
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-79

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

What each source says

CVE List

svelte performance oriented web framework. A potential mXSS vulnerability exists in Svelte for versions up to but not including 4.2.19. Svelte improperly escapes HTML on server-side rendering. The assumption is that attributes will always stay as such, but in some situation the final DOM tree rendered on browsers is different from what Svelte expects on server-side rendering. This may be leveraged to perform XSS attacks, and a type of the XSS is known as mXSS (mutation XSS). More specifically, this can occur when injecting malicious content into an attribute within a `noscript` tag. This issue has been addressed in release version 4.2.19. Users are advised to upgrade. There are no known workarounds for this vulnerability.

GitHub Advisory Database
Summary

A potential XSS vulnerability exists in Svelte for versions prior to 4.2.19.

Details

Svelte improperly escapes HTML on server-side rendering. It converts strings according to the following rules:

  • If the string is an attribute value:
    • " -> &quot;
    • & -> &amp;
    • Other characters -> No conversion
  • Otherwise:
    • < -> &lt;
    • & -> &amp;
    • Other characters -> No conversion

The assumption is that attributes will always stay as such, but in some situation the final DOM tree rendered on browsers is different from what Svelte expects on server-side rendering. This may be leveraged to perform XSS attacks. More specifically, this can occur when injecting malicious content into an attribute within a <noscript> tag.

PoC

A vulnerable page (+page.svelte):

<script>
import { page } from "$app/stores"

// user input
let href = $page.url.searchParams.get("href") ?? "https://example.com";
</script>

<noscript>
  <a href={href}>test</a>
</noscript>

If a user accesses the following URL,

http://localhost:4173/?href=</noscript><script>alert(123)</script>

then, alert(123) will be executed.

Impact

XSS, when using an attribute within a noscript tag

NVD (es)

Svelte es un framework web orientado al rendimiento. Existe una vulnerabilidad potencial mXSS en Svelte para las versiones hasta la 4.2.19, pero no incluida. Svelte escapa incorrectamente el HTML en la representación del lado del servidor. Se supone que los atributos siempre permanecerán como tales, pero en algunas situaciones el árbol DOM final representado en los navegadores es diferente de lo que Svelte espera en la representación del lado del servidor. Esto se puede aprovechar para realizar ataques XSS, y un tipo de XSS se conoce como mXSS (XSS de mutación). Más específicamente, esto puede ocurrir cuando se inyecta contenido malicioso en un atributo dentro de una etiqueta `noscript`. Este problema se ha solucionado en la versión de lanzamiento 4.2.19. Se recomienda a los usuarios que actualicen. No existen workarounds para esta vulnerabilidad.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-45047 changed 2024-08-30CVE Terms of Use
GitHub Advisory DatabaseGHSA-8266-84wp-wv5c changed 2024-08-30CC-BY-4.0
NVDCVE-2024-45047 changed 2026-06-17Public domain