Skip to content

[fix]: require token for local dev server - #3400

Merged
seanmcguire12 merged 2 commits into
mainfrom
browse-fn-token
Nov 5, 2026
Merged

seanmcguire12 merged 2 commits into
mainfrom
browse-fn-token

Conversation

@seanmcguire12

@seanmcguire12 seanmcguire12 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

why

browse functions dev should only accept runtime requests from the worker it starts.

what changed

  • this PR adds a random token for each dev server run and requires it when the worker receives invocations or returns results

Summary by cubic

Requires a random per-run token for browse functions dev runtime requests so only the worker the command starts can poll for invocations or post results, instead of any caller on the same port.

  • The runtime API path now includes a 32-byte token that the public invoke URL doesn't expose; swappable when the server restarts.
  • Rejects runtime poll, response, and error requests without the token with a 404.
  • Adds @browserbasehq/sdk-functions as a dev dependency to verify the dev server works with the real SDK.

Written for commit 18fd73e. Summary will update on new commits.

View guided diff Turn on auto-fix

@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 18fd73e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
browse Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​browserbasehq/​sdk-functions@​1.0.2761009994100

View full report

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant User as End User
    participant CLI as CLI Dev Server
    participant Runtime as Worker Runtime
    participant SDK as Functions SDK
    participant Browser as Browserbase API
    participant File as Handler Code

    Note over User,File: Function Invocation Flow

    User->>CLI: POST /v1/functions/test-function/invoke (public URL)
    CLI->>CLI: Generate 32-byte token, store in runtime API path
    CLI->>File: Invoke handler within worker process
    File->>Runtime: Execute business logic
    Runtime->>SDK: Poll for invocation (token-prefixed path)
    SDK->>CLI: GET /{token}/2018-06-01/runtime/invocation/next
    CLI->>Runtime: Return invocation payload
    Runtime->>SDK: Execute handler with payload
    SDK->>SDK: Process result
    
    alt Successful execution
        SDK->>CLI: POST /{token}/2018-06-01/runtime/invocation/{id}/response
        CLI->>Runtime: Completion acknowledged
        Runtime->>Browser: Release session (POST /v1/sessions/{id})
        Browser-->>Runtime: Session released
        Runtime-->>User: 200 + invocation result
    else Handler error
        SDK->>CLI: POST /{token}/2018-06-01/runtime/invocation/{id}/error
        CLI->>Runtime: Error received
        Runtime->>Browser: Release session (POST /v1/sessions/{id})
        Browser-->>Runtime: Session released
        Runtime-->>User: 500 + error details
    end

    Note over CLI,Runtime: Token Authentication

    alt Valid token in runtime path
        CLI->>Runtime: Accept poll/response/error request
    else Invalid or missing token
        CLI->>CLI: Return 404 (Not Found)
        Note over CLI: Rejects malicious/unintended callers<br/>Public invoke URL stays unchanged
    end

    Note over CLI,File: Hot Reload Flow

    File->>CLI: Detect file change in watched project
    CLI->>Runtime: Restart worker with new token
    Runtime->>SDK: Reconnect with fresh token
    SDK->>CLI: GET /{new-token}/2018-06-01/runtime/invocation/next
    CLI->>Runtime: Invalidate old token, accept new one
Loading

View guided diff | Turn on auto-fix | Re-trigger cubic

@seanmcguire12
seanmcguire12 merged commit ce298c6 into main Nov 5, 2026
61 checks passed
@seanmcguire12
seanmcguire12 deleted the browse-fn-token branch November 5, 2026 01:00
shrey150 pushed a commit that referenced this pull request Nov 13, 2026
Release Browse independently of the Stagehand SDKs. Merging this PR
publishes the CLI from the merged commit.

## 0.11.4

### Patch Changes

- [#3426](#3426)
[`f93e6d1`](f93e6d1)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Report an
error when an active browser session disconnects during command startup
instead of automatically starting a replacement.

- [#3379](#3379)
[`73fdba0`](73fdba0)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - remove
unused deepmerge dependency

- [#3330](#3330)
[`dc8eb40`](dc8eb40)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - bump zod to
4.6.6

- [#3289](#3289)
[`aa67fee`](aa67fee)
Thanks [@shrey150](https://github.com/shrey150)! - Add `--stagehand`
flag to `browse cloud extensions upload`.

- [#3439](#3439)
[`2fe947c`](2fe947c)
Thanks [@github-actions](https://github.com/apps/github-actions)! - Make
`browse doctor` fail and show the cause when the session's last browser
start failed

- [#3400](#3400)
[`ce298c6`](ce298c6)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Add token
validation to internal local Functions runtime requests

- [#3408](#3408)
[`6a56cbb`](6a56cbb)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Fix Windows
package-manager command launching for Functions and templates, and
terminate child processes when skill installation times out.

- [#3391](#3391)
[`3fbda6b`](3fbda6b)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - Validate
daemon directory locations before connecting to a session.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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