CVE-2026-27902: Svelte XSS Vulnerability via HTML Comment Injection in SSR Error Boundary Hydration Markers

svelte Updated 27 Feb 2026

Summary

26/02/2026
Yes i
Moderate
5.3

CVE-2026-27902: Svelte: XSS via HTML Comment Injection in SSR Error Boundary Hydration Markers. Affects svelte versions >= 5.53.0, < 5.53.5. Fixed in 5.53.5. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Svelte is a modern JavaScript framework for building user interfaces. It compiles components into highly optimized JavaScript at build time, allowing for fast and efficient web applications. Svelte's server-side rendering (SSR) capabilities enhance performance and SEO. However, a recent vulnerability has been identified that affects how errors are handled in SSR, potentially exposing applications to cross-site scripting (XSS) attacks.

Vulnerability Detail

The vulnerability arises from the improper escaping of error messages generated by the 'transformError' function. When these messages are included in the HTML output without proper sanitization, it allows an attacker to inject malicious HTML or JavaScript code. If an attacker can control the content returned by 'transformError', they can exploit this flaw to execute arbitrary scripts in the context of the user's browser, leading to potential data theft or session hijacking.

How To Fix

Latest published version: 5.57.2 as of 23 Oct 2026

npm install svelte@5.57.2

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

5.53.5

This is the first release that contains the fix.

npm install svelte@5.53.5

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, ensure that any error messages returned by 'transformError' are properly sanitized before being rendered in the HTML. You can implement a custom error handling function that escapes potentially dangerous characters. For example:

function safeTransformError(error) {
  return String(error).replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

Conclusion

The identified vulnerability in Svelte (CVE-2026-27902) poses a risk of XSS attacks due to improper error message handling in SSR. It is crucial for developers using Svelte to update to the patched version 5.53.5 to secure their applications. For those unable to update immediately, implementing a custom error handling function can serve as a temporary measure.

See every vulnerability recorded for svelte →

Share this vulnerability

FAQ

The CVSS score of this vulnerability is 5.3, indicating a moderate severity level.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

If exploited, this vulnerability can lead to XSS attacks, allowing attackers to execute malicious scripts in users' browsers, potentially leading to data theft or session hijacking.

Yes, a patch is available in Svelte version 5.53.5. It is recommended to update to this version to mitigate the risk.

If immediate updating is not possible, implement a custom error handling function to sanitize error messages as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for svelte.

How To Fix

Latest published version: 5.57.2 as of 23 Oct 2026

npm install svelte@5.57.2

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

5.53.5

This is the first release that contains the fix.

npm install svelte@5.53.5

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback