Svelte version 4.0.5 represents a minor update over its predecessor, 4.0.4, both iterations of the popular JavaScript framework known for building performant web applications by shifting work into a compile step. Examining the package metadata, the core dependencies remain identical, indicating that the fundamental parsing, code transformation, and accessibility features powered by libraries like acorn, code-red, css-tree, and aria-query haven't undergone significant changes. Similarly, the development dependencies, crucial for building, testing, and linting the Svelte codebase itself, are unchanged, implying stability in the underlying development toolchain. This includes tools like rollup for bundling, vitest for testing, and typescript for type checking, among others.
The key differentiator lies in the distribution metadata. Version 4.0.5 has a slightly larger unpacked size (2622094 bytes) compared to 4.0.4(2621843 bytes), suggesting minor additions or adjustments to the compiled output. More importantly, the release date reveals that version 4.0.5 was published on July 6, 2023, while 4.0.4 was released on July 4, 2023. This quick turnaround likely means 4.0.5 addresses bug fixes or minor enhancements identified shortly after the 4.0.4 release. Developers are advised to upgrade to the latest patch version (4.0.5), ensuring they benefit from the most recent bug fixes and improvements. This will contribute to a more stable and reliable experience during development and within their deployed applications.
All the vulnerabilities related to the version 4.0.5 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