-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
release-20.2: sql: Fix privilege checks to consider direct/indirect roles #58512
Conversation
67f95cc
to
059275c
Compare
statement ok | ||
CREATE USER testuser2; | ||
GRANT testuser TO testuser2; | ||
GRANT ALL ON SCHEMA s TO testuser2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be failing here
testdata/logic_test/privilege_builtins:1104:
expected success, but found
(3F000) unknown schema "s"
errors.go:60: in NewUndefinedSchemaError()
logic.go:2693:
testdata/logic_test/privilege_builtins:1104: error while processing
logic.go:2693: pq: unknown schema "s"
Does it need to be my_db.s
instead of just s
? I'm not sure why it fails in 20.2 but not in the original PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see... i had to remove that because this isn't (and won't be) backported to 20.2: #55647
hmm but i would have expected it to work since the current db is my_db... will investigate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see, probably because the user was switched to root.
Previously, privilege inquiry functions only looked for whether the user passed in in the first argument or current user had privileges on schemas, databases, tables, etc. with the built-ins such as `has_schema_privileges`, which was incorrect. This change makes sure that all roles the user is a direct or indirect member of are checked for privileges as well. Release note (bug fix): The has_${OBJECT}_privilege built-in methods such as `has_schema_privilege` now additionally checks whether roles the user is a direct or indirect member of also have privileges on the object. Previously only one user was checked which was incorrect. This bug has been present since version 2.0 but became more prominent as of v20.2 when role-based access control was included in CockroachDB Core.
059275c
to
4e2902c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I was supposed to review before you merge, but LGTM!
yes i needed your review! thank you :) |
Backport 1/1 commits from #58254.
/cc @cockroachdb/release
Resolves #57621
Previously, privilege inquiry functions only looked for whether
the user passed in in the first argument or current user had
privileges on schemas, databases, tables, etc. with the built-ins
such as
has_schema_privileges
, which was incorrect. This changemakes sure that all roles the user is a direct or indirect member
of are checked for privileges as well.
Release note (bug fix): The has_${OBJECT}_privilege built-in methods
such as
has_schema_privilege
now additionally checks whether rolesthe user is a direct or indirect member of also have privileges on
the object. Previously only one user was checked which was incorrect.
This bug has been present since version 2.0 but became more
prominent as of v20.2 when role-based access control was included in
CockroachDB Core.