Skip to content

Add databricks sandbox port-forward - #7367

Closed
cho15255 wants to merge 2 commits into
databricks:mainfrom
cho15255:sandbox-port-forward
Closed

cho15255 wants to merge 2 commits into
databricks:mainfrom
cho15255:sandbox-port-forward

Conversation

@cho15255

@cho15255 cho15255 commented Nov 5, 2026 •

Copy link
Copy Markdown

Changes

Add databricks sandbox port-forward [sandbox-id] -L LOCAL:REMOTE.... Each -L serves http://127.0.0.1:LOCAL and relays HTTP and WebSocket traffic to the app on sandbox port REMOTE through the workspace's /sandbox-proxy/sandboxes/<id>/ports/<port>/ route, authenticated as the caller. Without an ID it uses the default sandbox.

Every forwarded request carries the caller's credentials, so a forward:

  • binds to loopback and only accepts requests addressed to localhost;
  • refuses cross-site browser requests (by Origin and Sec-Fetch-Site), so neither a DNS-rebinding page nor a page on another site can use it, including over WebSockets;
  • replaces the local client's Authorization and X-Databricks-* headers with the CLI's;
  • refuses paths with . or .. segments, which the workspace would resolve outside the port route.

Remote ports outside 10000-65535 are rejected up front, and a stopped sandbox is started before forwarding, like sandbox ssh.

Why

Users can open apps running in their sandbox without setting up SSH. This is the CLI counterpart of the Python SDK's SandboxExt.port_forward. Like the rest of databricks sandbox, the command is hidden, so there is no changelog entry.

Tests

  • Unit tests for -L parsing, the request rewrite and its guards, WebSocket relay, auth failures, and sandbox resolution. Acceptance tests for argument and lookup errors.
  • Manually against a staging workspace: HTTP and WebSocket traffic, credential stripping, refused ports and hosts, an unknown sandbox, and Ctrl-C.

This pull request and its description were written by Isaac.

Forward local ports to apps in a sandbox: each -L LOCAL:REMOTE serves
http://127.0.0.1:LOCAL and relays HTTP and WebSocket traffic through the
workspace's /sandbox-proxy/sandboxes/<id>/ports/<port>/ route with the
caller's credentials. Forwards accept only localhost-addressed requests and
refuse dot-segment paths, so neither a DNS-rebinding page nor a crafted path
can use those credentials outside the port route.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for the contribution! This pull request was opened from a fork.

If you're a member of the Databricks organization, please request access to the cli-contrib team and open your pull request from a branch in this repository instead of a fork — fork PRs don't run integration tests automatically and have reduced CI access.

If you're an external contributor, no action is needed; a maintainer will review your pull request.

…oxes

Refuse browser requests from other sites (Origin, Sec-Fetch-Site) so a web
page can't use a forward, including over WebSockets. Reject remote ports
outside 10000-65535 at parse time, start a stopped sandbox before
forwarding like `sandbox ssh`, also serve the IPv6 loopback, and keep
net/http's error reports in the debug log.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 7367
  • Commit SHA: 024f57d965a14b3a87de50db580c88f0340ef955

Checks will be approved automatically on success.

@jaecho-db

Copy link
Copy Markdown

Superseded by #7395, opened from a branch in this repo.

@jaecho-db jaecho-db closed this Nov 7, 2026
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