Repository navigation
Conversation
…e reusing it `databricks ssh connect` keeps the tunnel's SSH keys in a secret scope with a predictable name and reused an existing scope without looking at who can access it. It now reuses an existing scope only when the scope is Databricks-backed and its ACL is exactly one entry, MANAGE for the current user, and fails before reading any key otherwise. The error says how to recover: delete the scope and connect again once no SSH server for the session is running, or on serverless connect with a different --name. The checks keep other principals from reading or replacing keys while the scope is in use. The ACL of an Azure Key Vault-backed scope would not, because it does not cover access through the vault. The checks do not prove who created the scope or wrote its secrets; keys in a scope that passes them are used as before. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/ssh/connect-scope-not-owned: branch ✅ | main (a0805a0) ❌ | latest (v1.28.0) ❌main (a0805a0): latest (v1.28.0): |
Collaborator
✅ Integration test reportCommit: 903c5be
Top 6 slowest tests (at least 2 minutes):
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
databricks ssh connectkeeps the SSH keys for a session in a secret scope named<user>-<session>-ssh-tunnel-keys. Before this change, the CLI reused that scope whenever it already existed. Now, when the scope exists,CreateKeysSecretScopeaccepts it only if both of these hold:The backend is checked first. A scope the CLI creates looks like that, because
CreateScopegrants MANAGE to its creator and the CLI sets noinitial_manage_principal.--name. On a dedicated cluster the session is the cluster ID, so that hint does not apply there.Client key handling is unchanged. The only change outside
internal/keysis thatclient.gopasses the serverless flag toCreateKeysSecretScope. The README gets a short section on the check and how to recover.Why
Before this change, any principal that also had access to the keys scope could read the client private key stored there, or replace the client public key that the server authorizes. The check refuses such a scope before the CLI uses it.
Behavior change for users
If a user's existing keys scope has any extra ACL entry (another user, a group, a service principal), or the user has only READ or WRITE on it,
ssh connectnow fails with this error (the last sentence appears only in serverless mode):The error says to wait for a running server because deleting the scope and connecting again right away does not work while a server for the session is still running. The CLI reuses that server, and the server still authorizes the client key it read at startup. Meanwhile the recreated scope gets a new client key pair and has no host key to pin. In the local fake workspace this reconnect fails with
failed to read the SSH server host key: ... server-public-key not found.What the check does not cover
This is a deliberate limit of the change, not an oversight. The check only shows that, right now, nobody else can read or change the scope. It does not show who created the scope or who wrote the secrets in it. Another principal could write keys, grant the user MANAGE and then remove its own entry. A scope that passes the check is used as before: the client reads the client key pair stored in it, and the server authorizes the client public key stored in it. That other principal still has no way to use such a key by itself: the tunnel runs only on serverless compute or on a dedicated single-user cluster, so another user cannot reach the session's SSH server. Requiring the scope's client key to match a key kept on the local machine would close this, but it would refuse a session's scope from a second machine or after the local key is removed, so it is left out.
Tests
experimental/ssh/internal/keys/secrets_test.gocover each ACL case: a missing scope is created; a single MANAGE entry for the user is accepted; a scope is refused when another user or a group also has access, when the user has only READ or WRITE, when only another principal has MANAGE, when the ACL list is empty, and when listing is denied; the--namehint appears only in serverless mode; any other listing error is returned; an Azure Key Vault-backed scope is refused before its ACL is listed; a scope missing from the scope list is an error. The tests assert the error text.acceptance/ssh/connect-scope-not-ownedsets up a scope with an extra ACL entry and stored keys. It checks thatssh connectfails with the error above, reports theSECRET_SCOPE_FAILEDcategory, and sends no request after the scope list and the ACL list: nosecrets/get, nosecrets/put, no upload and no job submit.go test ./experimental/ssh/... ./libs/testserver/...and allacceptance/sshtests pass locally.Not verified on a real workspace
principalalways equals the SCIMuserNamefor both users and service principals. If it does not for some identity, that identity's own scope would be refused.This pull request and its description were written by Isaac.