GHSA-pfhg-q3qv-9q6r: Medium severity npm/@sveltejs/kit vulnerability
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:
svelte <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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/@sveltejs/kitto a version that resolves this vulnerability.Fixed in 3.0.0 - Upgrade
Upgrade
@sveltejs/kitto a version that resolves this vulnerability.Fixed in 3.0.0 - Configuration
Disable navigation for non-redirect enhanced form results by supplying a custom submission callback.
SvelteKit enhanced form actions navigation for non-redirect enhanced form results = disabled - Compensating control
Reject requests whose parsed URL pathname begins with // before route resolution, such as in a reverse proxy or a SvelteKit handle hook.
Event History
Frequently Asked Questions
Which applications are exposed to this issue?
Applications using SvelteKit enhanced form actions via use:enhance are affected when they have routes, such as catch-all routes, that accept pathnames beginning with //.
What conditions are required for exploitation?
An attacker must be able to cause interaction with an enhanced form action whose route accepts a path beginning with //. The issue can result in an open redirect through protocol-relative URL handling.
What can be done if upgrading is not immediately possible?
Reject requests whose parsed URL pathname starts with // before route resolution, either at a reverse proxy or in a SvelteKit handle hook. Alternatively, configure enhanced forms with a custom submission callback that calls update({ navigate: false }) for non-redirect results.
Which version contains the fix?
Upgrade @sveltejs/kit to version 3.0.0 or later. The fix preserves leading double slashes without creating protocol-relative URLs and restricts non-redirect action navigation to the current origin.