Skip to content

fix(server): reject cross-site requests to /__open-in-editor - #24200

Open
mentatpsi wants to merge 1 commit into
vitejs:mainfrom
mentatpsi:fix/open-in-editor-csrf
Open

mentatpsi wants to merge 1 commit into
vitejs:mainfrom
mentatpsi:fix/open-in-editor-csrf

Conversation

@mentatpsi

@mentatpsi mentatpsi commented Nov 24, 2026 •

Copy link
Copy Markdown

There's a minor local developer pathway that allows an external actor to exploit the /__open-in-editor endpoint. It has little merit outside helping developers.

I have researched a bit, and I cannot find a legitimate pathway that allows for RCE... it can still spam the user and generally be a nuisance.

If the user is running a memory intensive editor like Visual Studio, for instance... a user could effectively be sent a minor DoS from an external site if the Editor decides to spawn the opening of the documents as separate processes. Essentially spamming them with a burst of open requests until the computer needs to be restarted. The attack does not persist, hence more a trolling. Worst case... it could cause the need for a restart mid development, risking lost work.

The code is minor and a simple cross site check. It only touches the endpoint and I've also pushed it to a helper function to avoid cluttering the index.ts

@mentatpsi
mentatpsi force-pushed the fix/open-in-editor-csrf branch from bf9b924 to c6f069c Compare November 24, 2026 05:41
@mentatpsi

mentatpsi commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

New tests are failing given CI differences. They're passing locally. I'll debug.

Hardening (not a reported vulnerability): the launch-editor middleware at
/__open-in-editor opens the developer's configured editor on a caller-
supplied file path with no origin check, so any page the developer visits
while the dev server runs can trigger it with a cross-site GET. Impact is
low (blind; opens existing files only), but the endpoint is easy to align
with how Vite already guards other dev-only endpoints.

Reject requests whose Sec-Fetch-Site is `cross-site`. Same-origin (Vite's
own client), same-site (e.g. another local dev port, since the port is not
part of the site, so cross-port setups keep working) and direct user
navigations are allowed. For clients that do not send Sec-Fetch-Site, fall
back to comparing the Origin hostname, ignoring the port; a request with no
Origin is a non-browser client and is allowed. No new dependencies.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mentatpsi
mentatpsi force-pushed the fix/open-in-editor-csrf branch from c6f069c to c841730 Compare November 24, 2026 05:50
@mentatpsi

Copy link
Copy Markdown
Author

Fixed. Feel free to decline the PR. It's just a minor quality of life improvement for developers.

@mentatpsi

Copy link
Copy Markdown
Author

Not to sure about the remaining CI pipelines. I read that it could just be race conditions. Can someone take a look?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant