sveltejs / sveltejs/kit

Disable nonce when using ISR

Open
#9,237 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

SvelteKit prevents you from using a nonce for CSP when prerendering pages (since otherwise it's predictable, and if it's predictable then it offers no protection), but not when you're using ISR.

Describe the proposed solution

Since the framework can't know that it's being used for ISR (SvelteKit is just handling a normal request, as far as it's concerned) I guess we'd basically have to check the config inside the adapter to make sure that mode === 'hash' if a) the app contains ISR routes, b) CSP config is present and c) it doesn't include unsafe-inline.

In the default case where mode === 'auto', I guess we could also add an API for telling SvelteKit 'we are effectively prerendering'. Or maybe we could just abuse the existing internal API for that.

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the adapter reads config and handles ISR routes, then compare that with the CSP nonce behavior described here. Resolve how to identify ISR, what should happen when mode is hash, and whether mode auto needs an API; the work is done when predictable nonces are prevented for ISR without unsafe-inline.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
security, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.