-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
infoschema: improve the security vunerability of TABLE_CONSTRAINTS infoschema #14037
Changes from 7 commits
71c58db
f300baf
3afba83
6154ac1
1a489ab
9b54fc6
d2a4546
2435b21
a60758b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,6 +445,25 @@ func (s *testTableSuite) TestSomeTables(c *C) { | |
tk.MustQuery("select * from information_schema.SESSION_VARIABLES where VARIABLE_NAME='tidb_retry_limit';").Check(testkit.Rows("tidb_retry_limit 10")) | ||
tk.MustQuery("select * from information_schema.ENGINES;").Check(testkit.Rows("InnoDB DEFAULT Supports transactions, row-level locking, and foreign keys YES YES YES")) | ||
tk.MustQuery("select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME='gc_delete_range';").Check(testkit.Rows("def mysql delete_range_index mysql gc_delete_range UNIQUE")) | ||
|
||
//test the privilege of new user for information_schema.table_constraints | ||
tk.MustExec("create user constraints_tester") | ||
constraintsTester := testkit.NewTestKit(c, s.store) | ||
constraintsTester.MustExec("use information_schema") | ||
c.Assert(constraintsTester.Se.Auth(&auth.UserIdentity{ | ||
Username: "constraints_tester", | ||
Hostname: "127.0.0.1", | ||
}, nil, nil), IsTrue) | ||
constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS;").Check([][]interface{}{}) | ||
|
||
//test the privilege of user with privilege of mysql.gc_delete_range for information_schema.table_constraints | ||
tk.MustExec("CREATE ROLE r_gc_delete_range ;") | ||
tk.MustExec("GRANT ALL PRIVILEGES ON mysql.gc_delete_range TO r_gc_delete_range;") | ||
tk.MustExec("GRANT r_gc_delete_range TO constraints_tester;") | ||
constraintsTester.MustExec("set role r_gc_delete_range") | ||
c.Assert(len(constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME='gc_delete_range';").Rows()), Greater, 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the exact count of rows? Is it unpredictable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the count of rows doesn't matter here. We want to check that we can read something here but don't care what it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it can be predicted, but may be changed in the future, and what we want is whether the data can be query, not what it is. |
||
constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME='tables_priv';").Check([][]interface{}{}) | ||
|
||
tk.MustQuery("select * from information_schema.KEY_COLUMN_USAGE where TABLE_NAME='stats_meta' and COLUMN_NAME='table_id';").Check( | ||
testkit.Rows("def mysql tbl def mysql stats_meta table_id 1 <nil> <nil> <nil> <nil>")) | ||
tk.MustQuery("select * from information_schema.STATISTICS where TABLE_NAME='columns_priv' and COLUMN_NAME='Host';").Check( | ||
|
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.
Use
.O
instead of.L
?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.
it doesn't matter, both can lead to the same thing, the schema.Name.L, tbl.Name.L will be converted to capital letters in this func.