[GH-ISSUE #5646] Dev and e2e server instances can rewrite the developer's working repo via the loopback channel-switch update bypass #3123

Closed
opened 2026-10-21 05:59:49 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5646

Originally assigned to: @kolacheee on GitHub.

What happens

The update-apply route allows a full git update — stash local changes, checkout the channel branch, pnpm install --force, rebuild — when the request is a loopback channel switch, even with UPDATES_APPLY_ENABLED unset (packages/server/src/routes/updates.routes.ts ~980: localChannelSwitchRequested bypasses the isUpdatesApplyEnabled() gate). That is reasonable for a real install, but the Playwright e2e servers and plain pnpm dev boot the same server from the developer's working repo — so any loopback browser tab pointed at a dev instance can rewrite the developer's checkout with one click of the channel selector.

This actually happened today: while e2e servers were running from the working repo (branch fix/5641-guarded-cache-writers, uncommitted changes present), a local tab's staging channel-switch applied a real update — auto-stash before update in the stash list, HEAD moved to staging, and a forced install/rebuild churned underneath two running Playwright sessions, wedging their boots. The stash preserved the uncommitted work (git did its job), but the repo silently changed branches mid-development and the e2e runs died in ways that looked like infrastructure flakiness.

Try it yourself

Run pnpm dev (or the Playwright suite, which boots the same dev servers) from a branch with uncommitted changes, open the app in a browser at its localhost port, and switch the update channel to staging in Settings. Watch git status / git stash list in the repo afterward.

Suggested direction

The e2e server launcher (e2e/start-servers.mjs) and dev launcher (scripts/dev.mjs) should set an env the apply route treats as a hard refusal — e.g. UPDATES_APPLY_DISABLED=true (checked before both the enabled flag and the channel-switch bypass), the same way the e2e env already sets MARINARA_E2E_DISABLE_RATE_LIMIT. A dev-instance apply attempt should get the manual-command message instead of mutating the repo. Detecting "working tree has uncommitted changes / non-channel branch checked out" and refusing the apply with a clear message would also protect contributors who run dev servers by other means.

Related: #5645 (the manual-command message those refusals fall back to has its own Windows-shell problems).

Found while investigating why local e2e runs kept wedging (2026-08-29).

Originally created by @kolacheee on GitHub (Aug 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5646 Originally assigned to: @kolacheee on GitHub. **What happens** The update-apply route allows a full git update — stash local changes, checkout the channel branch, `pnpm install --force`, rebuild — when the request is a loopback channel *switch*, even with `UPDATES_APPLY_ENABLED` unset (`packages/server/src/routes/updates.routes.ts` ~980: `localChannelSwitchRequested` bypasses the `isUpdatesApplyEnabled()` gate). That is reasonable for a real install, but the Playwright e2e servers and plain `pnpm dev` boot the same server *from the developer's working repo* — so any loopback browser tab pointed at a dev instance can rewrite the developer's checkout with one click of the channel selector. This actually happened today: while e2e servers were running from the working repo (branch `fix/5641-guarded-cache-writers`, uncommitted changes present), a local tab's staging channel-switch applied a real update — `auto-stash before update` in the stash list, HEAD moved to `staging`, and a forced install/rebuild churned underneath two running Playwright sessions, wedging their boots. The stash preserved the uncommitted work (git did its job), but the repo silently changed branches mid-development and the e2e runs died in ways that looked like infrastructure flakiness. **Try it yourself** Run `pnpm dev` (or the Playwright suite, which boots the same dev servers) from a branch with uncommitted changes, open the app in a browser at its localhost port, and switch the update channel to staging in Settings. Watch `git status` / `git stash list` in the repo afterward. **Suggested direction** The e2e server launcher (`e2e/start-servers.mjs`) and dev launcher (`scripts/dev.mjs`) should set an env the apply route treats as a hard refusal — e.g. `UPDATES_APPLY_DISABLED=true` (checked before both the enabled flag and the channel-switch bypass), the same way the e2e env already sets `MARINARA_E2E_DISABLE_RATE_LIMIT`. A dev-instance apply attempt should get the manual-command message instead of mutating the repo. Detecting "working tree has uncommitted changes / non-channel branch checked out" and refusing the apply with a clear message would also protect contributors who run dev servers by other means. Related: #5645 (the manual-command message those refusals fall back to has its own Windows-shell problems). Found while investigating why local e2e runs kept wedging (2026-08-29).
bsakaguchi 2026-10-21 05:59:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3123
No description provided.