Svelte 2.4.2 and 2.4.1 are closely related versions of the Svelte UI framework, a tool known for its "disappearing" nature – shifting the workload from the browser to the compilation step. Both versions share the same core description, author, license (MIT), and repository details, indicating a commitment to open-source principles and ongoing development by Rich Harris.
Examining the devDependencies, we see an extensive list of tools used for development, testing, and building the Svelte library. These include staples like rollup for bundling, typescript for type checking, eslint for code linting, and mocha and jsdom for testing. The presence of tools like css-tree, prettier, and magic-string points to features related to CSS processing, code formatting, and source code manipulation, respectively. Both versions depend on the same set of devDependencies, showcasing similar tooling and build processes.
The key differences lie in the dist object and the releaseDate. Svelte 2.4.2 was released on May 3, 2018, shortly after version 2.4.1 which premiered on May 1, 2018. The unpackedSize is slightly different - about 1KB smaller in the newer version. This suggests potential small optimizations or bug fixes made between the versions. Developers considering using Svelte should note the rapid iteration and relatively small size changes between versions, indicating active maintenance and optimization efforts. While the core functionality remains the same, picking the latest minor version (2.4.2) may offer better performance and stability.
All the vulnerabilities related to the version 2.4.2 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