|
|||||||||||
|
bk commit into 5.0 tree (evgen:1.2526) BUG#29908
From: <eugene(at)mysql.com>
Date: Thu Sep 20 2007 - 10:05:13 EDT
ChangeSet@1.2526, 2007-09-20 18:05:09+04:00, evgen@sunlight.local +3 -0 Bug#29908: A user can gain additional access through the ALTER VIEW. Non-definer of a view was allowed to alter that view. Due to this the alterer can elevate his access rights to access rights of the view definer and thus modify data which he wasn't allowed to modify. A view defined with SQL SECURITY INVOKER can't be used directly for access rights elevation. But a user can first alter the view SQL code and then alter the view to SQL SECURITY DEFINER and thus elevate his access rights. Due to this altering a view with SQL SECURITY INVOKER is also prohibited. Now the mysql_create_view function allows ALTER VIEW only to the view definer or a super user.
mysql-test/r/view_grant.result@1.26, 2007-09-20 17:48:10+04:00, evgen@sunlight.local +47 -3
Added a test case for the bug#29908: A user can gain additional access through the
ALTER VIEW.
mysql-test/t/view_grant.test@1.24, 2007-09-20 17:46:26+04:00, evgen@sunlight.local +47 -2
Added a test case for the bug#29908: A user can gain additional access through the
ALTER VIEW.
sql/sql_view.cc@1.118, 2007-09-20 18:03:16+04:00, evgen@sunlight.local +1 -4 Bug#29908: A user can gain additional access through the ALTER VIEW. Now the mysql_create_view function allows ALTER VIEW only to the view definer or a super user. diff -Nrup a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result --- a/mysql-test/r/view_grant.result 2007-06-05 22:17:58 +04:00@@ -776,15 +776,59 @@ GRANT CREATE VIEW ON db26813.v2 TO u2681 GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost; GRANT SELECT ON db26813.t1 TO u26813@localhost; ALTER VIEW v1 AS SELECT f2 FROM t1; -ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1' +ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v2 AS SELECT f2 FROM t1; -ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2' +ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v3 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v3; View Create View -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1`DROP USER u26813@localhost; DROP DATABASE db26813; +# +# Bug#29908: A user can gain additional access through the ALTER VIEW. +# +CREATE DATABASE mysqltest_29908; +USE mysqltest_29908; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE USER u29908_1@localhost; +CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1; +CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS +SELECT f1 FROM t1; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost; +CREATE USER u29908_2@localhost; +GRANT DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +ALTER VIEW v1 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; +View Create View +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` +DROP USER u29908_1@localhost; +DROP USER u29908_2@localhost; +DROP DATABASE mysqltest_29908; +####################################################################### DROP DATABASE IF EXISTS mysqltest1; DROP DATABASE IF EXISTS mysqltest2; CREATE DATABASE mysqltest1; diff -Nrup a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test --- a/mysql-test/t/view_grant.test 2007-03-23 18:56:41 +03:00@@ -1034,10 +1034,11 @@ GRANT SELECT ON db26813.t1 TO u26813@loc
connect (u1,localhost,u26813,,db26813);
connection u1;
connection root;
#
--- a/sql/sql_view.cc 2007-09-03 11:22:54 +04:00@@ -223,9 +223,6 @@ bool mysql_create_view(THD *thd, TABLE_L { LEX *lex= thd->lex; bool link_to_local; -#ifndef NO_EMBEDDED_ACCESS_CHECKS - bool definer_check_is_needed= mode != VIEW_ALTER || lex->definer; -#endif /* first table in list is target VIEW name => cut off it */ TABLE_LIST *view= lex->unlink_first_table(&link_to_local); TABLE_LIST *tables= lex->query_tables; @@ -280,7 +277,7 @@ bool mysql_create_view(THD *thd, TABLE_L
-- MySQL Code Commits Mailing List For list archives: http://lists.mysql.com/commits To unsubscribe: http://lists.mysql.com/commits?unsub=lists@pantek.comReceived on Thu Sep 20 12:06:58 2007 This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 09:35:21 EDT |
||||||||||
|
|||||||||||