Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: enforce privileges on the current descriptor for historical reads #51861

Open
ajwerner opened this issue Jul 23, 2020 · 8 comments
Open
Labels
A-schema-descriptors Relating to SQL table/db descriptor handling. A-security T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@ajwerner
Copy link
Contributor

ajwerner commented Jul 23, 2020

Describe the problem

Cockroach stores its user privileges with string user names. This means that a privilege on an old table may refer to a different user entity than the current name (if you say delete the user and recreate a user with the same name). Furthermore, it's probably not great that if you revoke access to a table then the user can still access it historically.

There is quite a bit of discussion on this topic in this thread here:
https://groups.google.com/a/cockroachlabs.com/g/sql-schema-team/c/L4oUTiceGY8/m/srPRdGgCAgAJ

Expected behavior

Ideally we'd not allow access to a table unless the user currently has privileges on the table. For deleted tables this probably means that we'd require that the user had permissions when the table was deleted.

Proposed Solution

In the relatively short term we should address this. One complication is being able to find the appropriate privileges for tables which have been deleted. It seems better to me to only do the right thing for non-deleted tables than to do what we do today but obvious a complete solution would be better.

Jira issue: CRDB-3999

@ajwerner ajwerner added A-schema-descriptors Relating to SQL table/db descriptor handling. A-security labels Jul 23, 2020
@ajwerner ajwerner added this to Triage in SQL Foundations via automation Jul 23, 2020
@ajwerner
Copy link
Contributor Author

This shouldn't be too crazy to implement and we should try to get it into this release. My feeling is that this falls on the sql schema team. cc @thtruo

@ajwerner
Copy link
Contributor Author

There has been some discussion of late in pushing permissions checking down into resolution. This would make solving this problem in the purvue of the descs.Collection easier. For now, I think a reasonable approach would be for the descs.Collection to recognize that a version of a table which has been acquired from the lease manager is historical, to request the latest version, and to copy the privileges off of that latest version.

@dt
Copy link
Member

dt commented Jul 23, 2020

I wonder if we should update a table when it is truncated with a pointer to its replacement? right now we only have the links in the other direction?

@ajwerner
Copy link
Contributor Author

I wonder if we should update a table when it is truncated with a pointer to its replacement? right now we only have the links in the other direction?

That's a good point. It begs the question about subsequent truncates. We could try to resolve the current privileges at the fully-qualified name but that leads to interesting questions about renames.

@ajwerner
Copy link
Contributor Author

#2939 is the issue about making users not strings.

@thoszhang thoszhang moved this from Triage to Backlog in SQL Foundations Jul 28, 2020
@jlinder jlinder added the T-sql-schema-deprecated Use T-sql-foundations instead label Jun 16, 2021
@postamar postamar moved this from Backlog to Triage in SQL Foundations Mar 11, 2022
@ajwerner
Copy link
Contributor Author

This one is legit and non-trivial

@rafiss
Copy link
Collaborator

rafiss commented Mar 13, 2023

CRDB-19134 is the new epic tracking the project to switch to use stable IDs for users.

@ajwerner
Copy link
Contributor Author

The use of IDs makes this situation better, but it's not super tightly coupled.

@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-schema-descriptors Relating to SQL table/db descriptor handling. A-security T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
SQL Foundations
  
Backlog
Development

No branches or pull requests

4 participants