mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-22374 VIEW with security definer require FILE privilege from definer not invoker in case of INTO OUTFILE
Already fixed by MDEV-39493; add a test for the view case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2096,3 +2096,43 @@ drop user 'root
|
||||
definer_host=localhost
|
||||
suid=1'@localhost;
|
||||
# End of 10.6 tests
|
||||
#
|
||||
# MDEV-22374: VIEW with security definer require FILE privilege from
|
||||
# definer not invoker in case of INTO OUTFILE
|
||||
#
|
||||
create user test@localhost;
|
||||
grant select on test.* to test@localhost;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
create definer=test@localhost sql security definer view v1 as select * from t1;
|
||||
# FILE privilege should be checked for the invoker, not the view definer
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from t1;
|
||||
select * from v1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select count(*) from v1) as dv1;
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select * from v1) as dv1;
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from v1;
|
||||
drop view v1;
|
||||
# Invoker without FILE privilege can not use the definer's one
|
||||
create definer=root@localhost sql security definer view v1 as select * from t1;
|
||||
connect con1, localhost, test;
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from t1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
|
||||
select * from v1;
|
||||
a
|
||||
1
|
||||
2
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select count(*) from v1) as dv1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select * from v1) as dv1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
|
||||
select * into outfile 'MYSQLTEST_VARDIR/tmp/mdev22374.txt' from v1;
|
||||
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
|
||||
disconnect con1;
|
||||
connection default;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
drop user test@localhost;
|
||||
# End of 10.11 tests
|
||||
|
||||
@@ -2346,5 +2346,57 @@ suid=1'@localhost;
|
||||
|
||||
--echo # End of 10.6 tests
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-22374: VIEW with security definer require FILE privilege from
|
||||
--echo # definer not invoker in case of INTO OUTFILE
|
||||
--echo #
|
||||
|
||||
create user test@localhost;
|
||||
grant select on test.* to test@localhost;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
create definer=test@localhost sql security definer view v1 as select * from t1;
|
||||
|
||||
--echo # FILE privilege should be checked for the invoker, not the view definer
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from t1
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/mdev22374.txt
|
||||
select * from v1;
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select count(*) from v1) as dv1
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/mdev22374.txt
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select * from v1) as dv1
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/mdev22374.txt
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from v1
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/mdev22374.txt
|
||||
drop view v1;
|
||||
|
||||
--echo # Invoker without FILE privilege can not use the definer's one
|
||||
create definer=root@localhost sql security definer view v1 as select * from t1;
|
||||
connect con1, localhost, test;
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from t1
|
||||
select * from v1;
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select count(*) from v1) as dv1
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from (select * from v1) as dv1
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
||||
--eval select * into outfile '$MYSQLTEST_VARDIR/tmp/mdev22374.txt' from v1
|
||||
disconnect con1;
|
||||
connection default;
|
||||
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
drop user test@localhost;
|
||||
|
||||
--echo # End of 10.11 tests
|
||||
|
||||
# Wait till we reached the initial number of concurrent sessions
|
||||
--source include/wait_until_count_sessions.inc
|
||||
|
||||
Reference in New Issue
Block a user