Skip to content

fix(config,vite,cli): share one studio transport guard across both dev hosts - #314

Closed
prisis wants to merge 2 commits into
alphafrom
advisor/296-studio-loopback-guard-unification
Closed

prisis wants to merge 2 commits into
alphafrom
advisor/296-studio-loopback-guard-unification

Conversation

@prisis

@prisis prisis commented Aug 2, 2026

Copy link
Copy Markdown
Member

Branched before #288/#289 landed, so it needs a rebase onto current alpha before merge.

Commits

  • fix(config,vite,cli): share one studio transport guard across both dev hosts
  • fix(config,vite,cli): add a forwarding-header escape hatch and dedupe headerValue

Files this branch still changes relative to alpha

api-snapshots/config.api.md
packages/cli/__tests__/util/studio-server.test.ts
packages/cli/src/util/studio-server.ts
packages/config/__tests__/studio-host/transport-guard.test.ts
packages/config/src/studio-host/index.ts
packages/config/src/studio-host/serve-json-handler.ts
packages/config/src/studio-host/transport-guard.ts
packages/vite/__tests__/studio-plugin.test.ts
packages/vite/src/studio-plugin.ts

prisis added 2 commits August 1, 2026 19:30
…v hosts

The Vite dev route and the standalone `lunora dev` studio server embed the
same worker admin token and proxy the same privileged surface, but each
guarded it differently: Vite checked the socket peer, the Host header, and
the absence of forwarding headers, while the CLI checked the Host header
literal only. A relay reaching the CLI server's loopback socket with
`Host: localhost` was served the token-bearing document and the admin proxy.

Move the stronger guard into the shared `@lunora/config/studio-host` layer
both hosts already depend on and delete the CLI's standalone check, so a
future hardening pass can't land on only one host again. Adopting the Vite
guard's semantics wholesale also changes two CLI behaviours deliberately: an
absent Host header is now permitted (a local non-browser client, once the
socket-peer check is in front), and a `0.0.0.0` Host literal is accepted
(harmless once the socket peer is already loopback).
… headerValue

Unifying the studio transport guard onto the Vite host's stricter check made
the standalone lunora dev server 403 every port-forwarded dev environment
that legitimately proxies from loopback (Codespaces, devcontainers, Gitpod,
Cloud Workstations, ngrok, Docker reverse proxies) with no way to recover and
no indication of why. transportRejectionReason now names the specific
forwarding header it saw in both the response body and a warnOnce through
whichever logger the host supplies, and LUNORA_STUDIO_ALLOW_FORWARDED=1 opts
out of just that check (the socket-peer and Host checks stay in force) once a
developer has confirmed the forwarding is their own trusted tunnel. The
module docblock also records why permitting an absent Host header is a
deliberate, low-impact relaxation rather than an oversight.

Also: serve-json-handler.ts still defined its own byte-identical headerValue
after the extraction — deleted it and imported the shared one. And commit the
config.api.md snapshot for the four newly-exported studio-host names, which
pnpm run api:check would otherwise catch failing in CI.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@prisis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e1c2964-64eb-4311-8985-50a7ec4c3459

📥 Commits

Reviewing files that changed from the base of the PR and between 6a4dd72 and 3f072e4.

⛔ Files ignored due to path filters (4)
  • api-snapshots/config.api.md is excluded by none and included by none
  • packages/cli/__tests__/util/studio-server.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
  • packages/config/__tests__/studio-host/transport-guard.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
  • packages/vite/__tests__/studio-plugin.test.ts is excluded by !**/__tests__/**, !**/*.test.ts and included by packages/**
📒 Files selected for processing (5)
  • packages/cli/src/util/studio-server.ts
  • packages/config/src/studio-host/index.ts
  • packages/config/src/studio-host/serve-json-handler.ts
  • packages/config/src/studio-host/transport-guard.ts
  • packages/vite/src/studio-plugin.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for lunorash failed.

Name Link
🔨 Latest commit 3f072e4
🔍 Latest deploy log https://app.netlify.com/projects/lunorash/deploys/6a6f0b8b009908000873ea8b

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for confirming the Contributor License Agreement! 🙏

@prisis

prisis commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Closing: this PR was opened in error by an automated run, outside the scope of its task.

No work is lost — the branch is retained on origin and this PR can be reopened at any time.

Context: this branch predates the merges of #288 and #289, so much of its content is already on alpha, and it would need a rebase before being reviewable. Reopening deliberately, after a rebase, is preferable to leaving it open in this state.

@prisis prisis closed this Aug 2, 2026
@prisis
prisis deleted the advisor/296-studio-loopback-guard-unification branch August 2, 2026 09:46
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using our GitHub Discussions tab for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant