Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
047eb225
Commit
047eb225
authored
Mar 17, 2021
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-25141 JSON_TABLE: SELECT into outfile bypasses file privilege check.
access rights checking fixed.
parent
abdc39b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
14 deletions
+15
-14
mysql-test/suite/json/r/json_table.result
mysql-test/suite/json/r/json_table.result
+2
-0
mysql-test/suite/json/t/json_table.test
mysql-test/suite/json/t/json_table.test
+6
-0
sql/sql_acl.cc
sql/sql_acl.cc
+4
-10
sql/sql_parse.cc
sql/sql_parse.cc
+3
-4
No files found.
mysql-test/suite/json/r/json_table.result
View file @
047eb225
...
...
@@ -111,6 +111,8 @@ a
select * from t, json_table(t.a, '$' columns(f varchar(20) path '$.foo')) as jt;
a f
{"foo":"bar"} bar
select * into outfile 'f' from json_table('[]', '$' columns(x for ordinality)) q;
ERROR 28000: Access denied for user 'u'@'localhost' (using password: NO)
connection default;
disconnect con1;
drop user u@localhost;
...
...
mysql-test/suite/json/t/json_table.test
View file @
047eb225
...
...
@@ -74,6 +74,12 @@ grant select (a) on db.t to u@localhost;
select
a
from
t
;
select
*
from
t
,
json_table
(
t
.
a
,
'$'
columns
(
f
varchar
(
20
)
path
'$.foo'
))
as
jt
;
#
# MDEV-25141 JSON_TABLE: SELECT into outfile bypasses file privilege check
#
--
error
ER_ACCESS_DENIED_ERROR
select
*
into
outfile
'f'
from
json_table
(
'[]'
,
'$'
columns
(
x
for
ordinality
))
q
;
connection
default
;
disconnect
con1
;
...
...
sql/sql_acl.cc
View file @
047eb225
...
...
@@ -8150,16 +8150,9 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables,
if
(
!
want_access
)
continue
;
// ok
if
(
t_ref
->
table_function
)
{
/* Table function doesn't need any privileges to be checked. */
t_ref
->
grant
.
privilege
|=
TMP_TABLE_ACLS
;
t_ref
->
grant
.
want_privilege
=
NO_ACL
;
continue
;
}
if
(
!
(
~
t_ref
->
grant
.
privilege
&
want_access
)
||
t_ref
->
is_anonymous_derived_table
()
||
t_ref
->
schema_table
)
t_ref
->
is_anonymous_derived_table
()
||
t_ref
->
schema_table
||
t_ref
->
table_function
)
{
/*
It is subquery in the FROM clause. VIEW set t_ref->derived after
...
...
@@ -8168,7 +8161,8 @@ bool check_grant(THD *thd, privilege_t want_access, TABLE_LIST *tables,
NOTE: is_derived() can't be used here because subquery in this case
the FROM clase (derived tables) can be not be marked yet.
*/
if
(
t_ref
->
is_anonymous_derived_table
()
||
t_ref
->
schema_table
)
if
(
t_ref
->
is_anonymous_derived_table
()
||
t_ref
->
schema_table
||
t_ref
->
table_function
)
{
/*
If it's a temporary table created for a subquery in the FROM
...
...
sql/sql_parse.cc
View file @
047eb225
...
...
@@ -7104,9 +7104,6 @@ check_table_access(THD *thd, privilege_t requirements, TABLE_LIST *tables,
if
(
table_ref
->
is_anonymous_derived_table
())
continue
;
if
(
table_ref
->
table_function
)
continue
;
if
(
table_ref
->
sequence
)
{
/* We want to have either SELECT or INSERT rights to sequences depending
...
...
@@ -7116,7 +7113,9 @@ check_table_access(THD *thd, privilege_t requirements, TABLE_LIST *tables,
INSERT_ACL
:
SELECT_ACL
);
}
if
(
check_access
(
thd
,
want_access
,
table_ref
->
get_db_name
(),
if
(
check_access
(
thd
,
want_access
,
table_ref
->
table_function
?
any_db
:
table_ref
->
get_db_name
(),
&
table_ref
->
grant
.
privilege
,
&
table_ref
->
grant
.
m_internal
,
0
,
no_errors
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment