Svelte 3.0.0 marks a significant evolution from version 2.16.1, offering developers a refined and enhanced experience in building performant web applications. A key difference lies in the core description, moving from "The magical disappearing UI framework" to "Cybernetically enhanced web apps," hinting at a more mature and powerful tool. Both versions share the MIT license and the same author, Rich Harris, ensuring continuity of development philosophy.
Delving into the developer dependencies reveals notable changes. Version 3.0.0 upgrades several crucial tools, like rollup (from 0.63.5 to ^1.1.2), typescript (keeping it at ^3.0.1 but reflecting evolving integration needs), and rollup-plugin-typescript (from 0.8.1 to ^1.0.0), suggesting improved build processes and better TypeScript support. The removal of dependencies like nyc, sade, chalk, sander, shelljs, prettier, nightmare, node-resolve, rollup-watch, console-group, and rollup-plugin-buble indicates a shift in the development workflow, potentially towards a leaner or different testing and building approach.
The introduction of @sveltejs/svelte-repl in version 3.0.0 is particularly interesting, signaling the availability of an official REPL environment for rapid prototyping and experimentation. While both versions have a similar unpacked size, the increase in file count in the distribution of v3.0.0 suggests architectural changes and likely more granular modules for improved tree-shaking. Ultimately, version 3.0.0 signifies a next-generation Svelte experience, fine-tuned for enhanced developer productivity and application performance.
All the vulnerabilities related to the version 3.0.0 of the package
Svelte vulnerable to XSS when using objects during server-side rendering
The package svelte before 3.49.0 is vulnerable to Cross-site Scripting (XSS) due to improper input sanitization and to improper escape of attributes when using objects during SSR (Server-Side Rendering). Exploiting this vulnerability is possible via objects with a custom toString() function.
Svelte has a potential mXSS vulnerability due to improper HTML escaping
A potential XSS vulnerability exists in Svelte for versions prior to 4.2.19.
Svelte improperly escapes HTML on server-side rendering. It converts strings according to the following rules:
"
-> "
&
-> &
<
-> <
&
-> &
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.
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.
XSS, when using an attribute within a noscript tag