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: support tracking which users grant privileges for revoke compatibility #71999

Open
jackcwu opened this issue Oct 26, 2021 · 3 comments
Open
Labels
A-sql-privileges SQL privilege handling and permission checks. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@jackcwu
Copy link
Contributor

jackcwu commented Oct 26, 2021

As described in the Postgres docs: https://www.postgresql.org/docs/14/sql-revoke.html

A user can only revoke privileges that were granted directly by that user. If, for example, user A has granted a privilege with grant option to user B, and user B has in turn granted it to user C, then user A cannot revoke the privilege directly from C.
Instead, user A could revoke the grant option from user B and use the CASCADE option so that the privilege is in turn revoked from user C. For another example, if both A and B have granted the same privilege to C, A can revoke their own grant but not B's grant, so C will still effectively have the privilege.

Currently, CockroachDB lets any user revoke privileges on another user, given that the revoking user has the appropriate privileges. To reproduce this issue, from root, do:

create user grantselect with password 'roach';
create user revokeselect with password 'roach';
create user target with password 'roach';
create table tt(row INT);
grant all privileges on table tt to grantselect with grant option;
grant all privileges on table tt to revokeselect with grant option;
# switch to grantselect
grant all privileges on table tt to target with grant option;
# switch to revokeselect
revoke all privileges on table tt from target;
show grants on table tt;

the user 'target' will have its privileges revoked by a user that did not create it, which is not consistent with the behavior of Postgres

Jira issue: CRDB-10892

@jackcwu jackcwu added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-privileges SQL privilege handling and permission checks. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Oct 26, 2021
@rafiss
Copy link
Collaborator

rafiss commented Oct 26, 2021

This would allow us to fix #67442

@chengxiong-ruan
Copy link
Contributor

Would allow us to fix #88155 as well

Copy link

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-privileges SQL privilege handling and permission checks. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

3 participants