Svelte 4.2.0 represents a minor version upgrade over its predecessor, Svelte 4.1.2, both maintaining the core philosophy of "Cybernetically enhanced web apps." Examining the package data, the dependency trees remain identical, indicating no alterations in the core tooling required for Svelte's compilation process. Both versions rely on the same versions of crucial libraries like acorn for JavaScript parsing, css-tree for CSS parsing, and @jridgewell/trace-mapping for source map handling which makes svelte reliable and compliant with standards.
Crucially, the development dependencies, outlining tools used during the development of Svelte itself, are also consistent. This suggests that the development environment, testing frameworks (like vitest, happy-dom, @playwright/test), and build tools (like rollup, esbuild) remain stable between the two versions.
The most notable differences lie in the dist section. Svelte 4.2.0 has a slightly larger unpacked size (2621966 bytes) and file count (248) compared to Svelte 4.1.2 (2610843 bytes and 247 files respectively). While seemingly minor, these variations could indicate bug fixes, performance improvements, or subtle internal refactoring within the Svelte compiler itself. Developers might experience slightly optimized build times or marginal rendering performance gains when upgrading. The release date of 2023-08-11 for 4.2.0, compared to 2023-07-31 for 4.1.2, signifies a relatively short period between releases, further supporting the idea of targeted improvements rather than extensive feature additions. For developers already using Svelte 4, upgrading to 4.2.0 is likely a safe and potentially beneficial move, offering stability and incremental enhancements without introducing breaking changes.
All the vulnerabilities related to the version 4.2.0 of the package
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