Skip to content

sql,security: gate session revival behind a cluster setting#75660

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:session-revival-cluster-setting
Feb 17, 2022
Merged

sql,security: gate session revival behind a cluster setting#75660
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:session-revival-cluster-setting

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented Jan 28, 2022

fixes #74643

Stop allowing any multitenant cluster from using this functionality.

Release note (security update): The cluster setting
server.user_login.session_revival_token.enabled has been added. It is
false by default. If it is set to true, then a new
token-based authentication mechanism is enabled. A token can be
generated using the crdb_internal.create_session_revival_token builtin
function. The token has a lifetime of 10 minutes and is
cryptographically signed to prevent spoofing and brute-forcing attempts.
When initializing a session later, the token can be presented in a
pgwire StartupMessage with a parameter name of
crdb:session_revival_token_base64, with the value encoded in base64.
If this parameter is present, all other authentication checks are
disabled, and if the token is valid and has a valid signature, the user
who originally generated the token authenticates into a new SQL
session. If the token is not valid, then authentication fails.

The token does not have "use-once" semantics, so the same token can be
used any number of times to create multiple new SQL sessions within the
10 minute lifetime of the token. As such, the token should be treated as
highly sensitive cryptographic information.

This feature is meant to be used by multitenant deployments to move a
SQL session from one node to another. It requires the presence of a
valid Ed25519 keypair in tenant-signing.<tenant_id>.crt and
tenant-signing.<tenant_id>.key.

@rafiss rafiss added the do-not-merge bors won't merge a PR with this label. label Jan 28, 2022
@rafiss rafiss requested review from a team, jaylim-crl, jeffswenson and knz January 28, 2022 18:33
@rafiss rafiss requested a review from a team as a code owner January 28, 2022 18:33
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Jan 28, 2022

To reviewers: let's use this PR to discuss the correct way to gate this functionality. At the time of writing this comment, the TenantReadOnly cluster setting does not work. So we can either wait for that functionality to be implemented, or change the gating to use an environment variable.

Copy link
Copy Markdown
Contributor

@jaylim-crl jaylim-crl left a comment

Choose a reason for hiding this comment

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

If I understand correctly, this cluster setting will be on the host cluster right? Does that also mean the host could use this revival token? And if that's true, is there a way to only restrict it to tenants?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jeffswenson and @knz)

Copy link
Copy Markdown
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

The host cluster won't have the certs, so it won't be able to use tokens. But that's not a very explicit guard, so yes, I should be able to change this to disallow it on host clusters always.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jeffswenson and @knz)

@knz
Copy link
Copy Markdown
Contributor

knz commented Jan 31, 2022

What is the timeline to support tenant-read-only settings?

(Whatever the outcome of the discussion is, the new feature gate should be kept coherent with the one used to support crdb:remote_addr, i.e. we should use the same configuration mechanism for both. If we are successful adding a tenant-read-only cluster setting for one feature, we should also introduce a setting for the other.)

@RaduBerinde
Copy link
Copy Markdown
Member

What is the timeline to support tenant-read-only settings?

I'd say in a few weeks, end of Feb at the latest.

@jeffswenson
Copy link
Copy Markdown
Collaborator

From the standpoint of CC automation, gating this with an environment variable or a tenant read-only setting is equally convenient.

@rafiss rafiss force-pushed the session-revival-cluster-setting branch from 4b1c30a to 44018bb Compare February 12, 2022 23:39
Stop allowing any multitenant cluster from using this functionality.

Release note (security update): The cluster setting
server.user_login.session_revival_token.enabled has been added. It is
false by default. If it is set to true, then a new
token-based authentication mechanism is enabled. A token can be
generated using the crdb_internal.create_session_revival_token builtin
function. The token has a lifetime of 10 minutes and is
cryptographically signed to prevent spoofing and brute-forcing attempts.
When initializing a session later, the token can be presented in a
pgwire StartupMessage with a parameter name of
`crdb:session_revival_token_base64`, with the value encoded in base64.
If this parameter is present, all other authentication checks are
disabled, and if the token is valid and has a valid signature, the user
who originally generated the token authenticates into a new SQL
session. If the token is not valid, then authentication fails.

The token does not have "use-once" semantics, so the same token can be
used any number of times to create multiple new SQL sessions within the
10 minute lifetime of the token. As such, the token should be treated as
highly sensitive cryptographic information.

This feature is meant to be used by multitenant deployments to move a
SQL session from one node to another. It requires the presence of a
valid Ed25519 keypair in tenant-signing.<tenant_id>.crt and
tenant-signing.<tenant_id>.key.
@rafiss rafiss force-pushed the session-revival-cluster-setting branch from 44018bb to 02a0943 Compare February 14, 2022 22:39
@rafiss rafiss removed the request for review from a team February 16, 2022 05:27
@rafiss rafiss changed the title [DNM] sql,security: gate session revival behind a cluster setting sql,security: gate session revival behind a cluster setting Feb 16, 2022
@rafiss rafiss removed the do-not-merge bors won't merge a PR with this label. label Feb 16, 2022
@rafiss rafiss requested a review from a team February 16, 2022 16:47
@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Feb 16, 2022

ok, this is ready for review -- let's merge it like this with the TenantWriteable setting, and once @RaduBerinde + @ajstorm complete the work for TenantReadOnly settings, we can change it at that point.

Copy link
Copy Markdown
Collaborator

@jeffswenson jeffswenson left a comment

Choose a reason for hiding this comment

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

LGTM!

With the caveat I expect the setting to use TenantReadOnly as soon as the option is available.

@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Feb 17, 2022

tftr!

bors r=JeffSwenson,otan

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 17, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 17, 2022

Build succeeded:

@craig craig bot merged commit a6ef4b0 into cockroachdb:master Feb 17, 2022
@rafiss rafiss deleted the session-revival-cluster-setting branch February 18, 2022 17:45
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.

sql,security: add functionality to revive a SQL session in multitenant clusters

7 participants