Skip to content

fix(security): studio loopback + token; vargai needs @vargai/mcp ^0.20.0 (alpha125) - #252

Merged
SecurityQQ merged 1 commit into
mainfrom
fix/studio-and-mcp-floor
Oct 31, 2026
Merged

SecurityQQ merged 1 commit into
mainfrom
fix/studio-and-mcp-floor

Conversation

@SecurityQQ

Copy link
Copy Markdown
Contributor

What was open

vargai@0.4.0-alpha124 (npm latest) ships vargai studio: POST /api/render imports and runs the TSX it is sent, on a server bound to every interface with no auth. Anyone on the same network — or any web page, via a cross-site text/plain POST to localhost:8282 — could run code on the machine.

#251 already removed the studio command from the CLI for alpha125, but vargai/studio (and bun run studio) still start the same server.

Fix

  • studio binds 127.0.0.1
  • per-launch token (VARG_STUDIO_TOKEN or random 256-bit): the printed URL carries it once (/?token=… → 302 + HttpOnly; SameSite=Strict cookie), or Authorization: Bearer
  • Host must be 127.0.0.1:<port> / localhost:<port> → DNS rebinding gets 403
  • vargai mcp … resolves @vargai/mcp@^0.20.0 — the release with the upload_file / --http fixes (vargHQ/mcp#59)

Tests

src/studio/server.test.ts (in test:ci): no token 401, foreign Host 403, token link → cookie, LAN address refused. test:ci: 445 pass, 0 fail; tsc --noEmit clean.

Release plan: publish 0.4.0-alpha125 as latest/alpha, deprecate ≤ alpha124.

🤖 Generated with Claude Code

…^0.20.0

studio's POST /api/render runs the code it is sent, and the server listened
on every interface with no check: remote code execution for anyone on the
network, and for any web page through a cross-site POST to localhost:8282.
Now it binds 127.0.0.1, wants a per-launch token (the printed URL carries it
once, then an HttpOnly SameSite=Strict cookie, or a bearer), and refuses any
Host but 127.0.0.1/localhost so a DNS-rebinding page cannot reach it.

`vargai mcp` / every MCP command now resolves @vargai/mcp@^0.20.0, the first
release whose upload_file{path} stays in the project and asks, and whose
--http is loopback + token (vargHQ/mcp#59).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

Studio now binds to loopback and requires a token for requests. Its CLI uses the server-provided URL. The change also updates the MCP fallback package version and adds Studio server tests to the CI test script.

Changes: studio server access

Layer / File(s) Summary
Token and request guard
src/studio/server.ts
The server binds to 127.0.0.1, checks request hosts and credentials, and returns a tokenized URL with the bound port.
URL use and access tests
src/studio/index.ts, src/studio/server.test.ts, package.json
The CLI prints the returned URL. Tests cover token access, host rejection, cookie authorization, network reachability, and cleanup. The CI test script now runs the server tests.

mcp fallback version

Layer / File(s) Summary
Fallback package range
src/cli/commands/mcp.ts, src/cli/commands/mcp.test.ts
The fallback range and test expectation change to @vargai/mcp@^0.20.0. The comment describes the release’s file-upload and HTTP characteristics.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant StudioClient
  participant BunServer
  participant guard
  participant StudioRoutes
  StudioClient->>BunServer: request tokenized URL
  BunServer->>guard: validate host and token
  guard-->>StudioClient: redirect and set strict cookie
  StudioClient->>BunServer: request with cookie
  BunServer->>guard: validate cookie
  guard-->>BunServer: allow request
  BunServer->>StudioRoutes: route request
Loading

Possibly related PRs

  • vargHQ/sdk#251: removes the Studio CLI command and marks the Studio API as deprecated; this PR changes the same server’s binding, authentication, and returned URL.

Suggested reviewers: caffeinum

Merge Risk: Moderate · up to 24394

Studio now binds to loopback and requires a token, which closes the original network exposure. However, a web page served from another local port can still send authenticated render requests through the browser cookie and run code, so add an Origin check or a CSRF token before merging. A custom token containing special characters can also produce a printed link that does not log in.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

loopback keeps the server near
a token guards the path
a cookie clears the query
the cli prints the given url
mcp’s version steps ahead
tests trace the gates, meow

@SecurityQQ
SecurityQQ merged commit 97310de into main Oct 31, 2026
1 of 3 checks passed
@SecurityQQ
SecurityQQ deleted the fix/studio-and-mcp-floor branch October 31, 2026 06:58
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