Skip to content

fix(cli): bind studio preview server to loopback by default#1210

Merged
vanceingalls merged 1 commit into
mainfrom
06-04-fix_cli_bind_studio_preview_server_to_loopback_by_default
Jun 5, 2026
Merged

fix(cli): bind studio preview server to loopback by default#1210
vanceingalls merged 1 commit into
mainfrom
06-04-fix_cli_bind_studio_preview_server_to_loopback_by_default

Conversation

@vanceingalls
Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls commented Jun 5, 2026

Summary

  • Binds the Studio preview server (packages/cli) to 127.0.0.1 instead of 0.0.0.0 so it is only reachable from localhost.
  • Adds a --host flag for callers that genuinely need to expose the server on a wider interface (e.g. Docker, remote dev boxes).

Security

F-001 HIGH — Studio preview server was binding on all interfaces, making it reachable from any network the developer's machine was on (including shared Wi-Fi, corp LAN). Because the server serves the project filesystem under no auth, any peer on the same network could read arbitrary project files. Restricting to loopback closes this exposure for the default case.

Test plan

  • hyperframes preview starts — server reachable on localhost:<port>, not on LAN IP
  • hyperframes preview --host 0.0.0.0 still binds on all interfaces for Docker / remote-dev use cases
  • Existing unit tests pass

Copy link
Copy Markdown
Collaborator Author

vanceingalls commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: #1210 — bind studio preview server to loopback by default

Correct fix. A few notes:


  • was previously exported, now de-exported. If any external consumer imports it, this is a breaking change. Quick grep to confirm it's internal-only would be prudent.
  • — correct precedence: explicit arg wins, then env var, then default loopback.
  • Passing as an optional parameter at the end of the signature is backward-compatible. ✓

Tests

  • refactor is a nice cleanup.
  • helper correctly distinguishes from string/null. ✓
  • Both the default-loopback and explicit-0.0.0.0 cases are covered. ✓

No blocking issues. LGTM.

Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: #1210 — bind studio preview server to loopback by default

Correct fix. A few notes:

portUtils.ts

  • getProcessOnPort was previously exported, now de-exported. If any external consumer imports it, that's a breaking change — quick grep to confirm it's internal-only is worth doing.
  • bindHost ?? (process.env.HYPERFRAMES_PREVIEW_HOST?.trim() || "127.0.0.1") — correct precedence: explicit arg wins, then env var, then default loopback. ✓
  • Adding bindHost as an optional param at the end of the signature is backward-compatible. ✓

Tests

  • closeAll refactor is a nice cleanup.
  • boundAddress helper correctly distinguishes AddressInfo from string/null. ✓
  • Both the default-loopback and explicit 0.0.0.0 cases are covered. ✓

No blocking issues. LGTM.

Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Minor: confirm is internal-only since it was de-exported.

Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Minor: confirm getProcessOnPort is internal-only since it was de-exported.

The studio preview server bound the unspecified address (0.0.0.0 / ::) via a
bare listen(port), exposing the unauthenticated studio API -- project file
read/write/delete and render-spawn endpoints -- to anyone on the same LAN.
Default the bind host to 127.0.0.1 and add an explicit "preview --host"
opt-in (with a warning) for intentional LAN exposure.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vanceingalls vanceingalls force-pushed the 06-04-fix_cli_bind_studio_preview_server_to_loopback_by_default branch from 488f5e3 to 74fb9d2 Compare June 5, 2026 21:06
@vanceingalls
Copy link
Copy Markdown
Collaborator Author

Confirmed: getProcessOnPort has zero references outside portUtils.ts — it's internal-only, de-export is safe.

@vanceingalls vanceingalls merged commit 1324de5 into main Jun 5, 2026
35 checks passed
@vanceingalls vanceingalls deleted the 06-04-fix_cli_bind_studio_preview_server_to_loopback_by_default branch June 5, 2026 21:48
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.

2 participants