Packages / @sveltejs/kit / Security
SvelteKit: URL redirection to untrusted site via enhanced form submission
Affected releases · @sveltejs/kit
- 2.x2.0.0 – 2.70.3No fix on this line yet
- 1.x and older0.0.8 – 1.30.4No fix, no longer updated
2.x has no fix yet; the newest fixed line:
npm install @sveltejs/kit@3.0.0Not affected
3.0.0 – 3.1.0
3 releases, latest
Affected
2.0.0 – 2.70.3
237 releases
Affected
1.0.0 – 1.30.4
128 releases
Affected
0.0.8 – 0.0.30
21 releases
Is your project affected?
Paste your package.json, or type the range you declare for @sveltejs/kit. It is read in your browser and sent nowhere.
What happens
Impact
Applications using enhanced form actions (use:enhance) on routes that accept paths beginning with //, such as catch-all routes, may be vulnerable to an open redirect.
Patches
A fix has been prepared for @sveltejs/kit 3.0.0. Users should upgrade to 3.0.0 or later.
The fix preserves leading double slashes in action paths without generating protocol-relative URLs, restricts non-redirect action navigation to the current origin, and includes the origin when comparing action locations with the current page.
Workarounds
Reject requests whose parsed URL pathname begins with // before route resolution, for example in a reverse proxy or a SvelteKit handle hook.
Alternatively, disable navigation for non-redirect enhanced form results by supplying a custom submission callback:
<form method="POST" use:enhance={() => ({ update }) => update({ navigate: false })}>
<!-- form fields -->
</form>This applies non-redirect results to the current page instead of navigating to the action location.