Repository navigation
Answer only this machine, and serve a built Docent on http - #44
Merged
Merged
Conversation
… from Docent's own pages Only /mcp checked the Host before, and only the provider routes checked where a change came from, so a domain rebound to this machine could reach everything else, and in dev any site could send changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adapter-node assumes https unless a proxy says otherwise, so a built Docent's URLs and the origin SvelteKit checks requests against both claimed https: saving a provider's key command was refused, and remote functions would be too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s on http Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vivecuervo7
commented
Nov 7, 2026
…ther site frame it Started with node build, a built Docent takes itself to be https and would refuse every change its own pages make. In a frame on another site, clicks the user was tricked into would come from Docent's own page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hook moves beside the request checks as one function, so its answers can be tested without starting Docent's background work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vivecuervo7
commented
Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
localhost,127.0.0.1,[::1], any port), and a change (anything but GET, HEAD, OPTIONS) that carries an Origin must come from Docent's own origin. This is one check inhandle,refusal()inrequestGuard.server.ts, which replaces the/mcp-only Host check./mcpkeeps its JSON-RPC error shape. The guard leaves a change with no Origin to the route, so agents' JSON requests are unaffected; a built Docent's SvelteKit still refuses a bodiless one with no Origin, as before.frame-ancestors 'none'), since clicks inside a frame would otherwise come from Docent's own page.node build, which would take itself to be https, answers with a 500 that says to usenpm start.fromThisApp, now just the Origin comparison).npm startrunsserver.js: adapter-node's handler on plain http, with each request told so, plus a clean shutdown on SIGINT/SIGTERM.sendWithoutBodyworkaround from Move to SvelteKit 3 #43 is removed.Why
Only
/mcpchecked the Host, and only the provider routes checked Origin, so a domain rebound to this machine could reach every other route, including those that post reviews and resolve threads as the user. In dev, where SvelteKit's own CSRF check is off, any site could send changes.Separately, adapter-node assumes https unless a proxy says otherwise, so a built Docent's URLs and the origin SvelteKit checks requests against both claimed
https://. Saving a provider's key command was refused in production. SvelteKit 3 also forbids any remote-function call whose Origin isn't the server's own, ignoringtrustedOrigins, so remote functions would have failed in production too. Settingpaths.originwould only have patched SvelteKit's comparison: it bakes the port in at build time and leavesevent.urlclaiming https.How
Once the server's origin comes from the Host header, a rebound domain's Origin matches it, so SvelteKit's CSRF check can't stop rebinding. The Host allowlist in
handleis what does, and its comment says so.Checked on a production build with a copy of the data, before and after:
/apiand/mcp. A foreign ornullOrigin on a change gets 403. Agents'/mcpcalls with no Origin go through, and a spoofed protocol header is overwritten._appassets and[::1]are served; the start page, Settings, Stats and a PR render in a browser with no errors.node build, the start page shows thenpm startmessage. A browser refuses to frame Docent from another origin.Also in dev: a rebound Host and a foreign-Origin change are both refused; pages and Vite's client load.
Not covered here: SvelteKit's remote-function origin check can't be exercised until a remote function exists. This PR makes
event.urltruthful, and the Stats slice will exercise the check against a production build. Separately, withHOST=localhosta built Docent listens on IPv6::1only on this Mac, so127.0.0.1isn't reachable. That predates this PR and is tracked separately.🤖 Generated with Claude Code