Skip to content

Commit 7d10c82

Browse files
gkodinovdahlerlend
authored andcommitted
Bug #31077699: NORMAL USER CAN CREATE VIEW/PROC/TRIG WITH
DEFINER=USER_WITH_SYSTEM_USER_PRIV RB#24132 The fetch of the ACL map for the current user was done based on the login user and not the authenticated user. This caused artificially created execution contexts that lack the login user being set to find the wrong ACL map. Fixed by using the privileged user instead.
1 parent a4b2a21 commit 7d10c82

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

sql/auth/sql_security_ctx.cc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,26 +389,29 @@ void Security_context::checkout_access_maps(void) {
389389
if (m_acl_map != nullptr) {
390390
DBUG_PRINT(
391391
"info",
392-
("(checkout) Security_context for %s@%s returns Acl_map to cache. "
392+
("(checkout) Security_context for %.*s@%.*s returns Acl_map to cache. "
393393
"Map reference count= %u",
394-
m_user.c_ptr(), m_host.c_ptr(), m_acl_map->reference_count()));
394+
(int)m_priv_user_length, m_priv_user, (int)m_priv_host_length,
395+
m_priv_host, m_acl_map->reference_count()));
395396
get_global_acl_cache()->return_acl_map(m_acl_map);
396397
m_acl_map = nullptr;
397398
}
398399

399400
if (m_active_roles.size() == 0) return;
400401
++m_map_checkout_count;
401402
Auth_id_ref uid;
402-
uid.first.str = this->m_user.ptr();
403-
uid.first.length = this->m_user.length();
404-
uid.second.str = this->m_host_or_ip.ptr();
405-
uid.second.length = this->m_host_or_ip.length();
403+
uid.first.str = this->m_priv_user;
404+
uid.first.length = this->m_priv_user_length;
405+
uid.second.str = this->m_priv_host;
406+
uid.second.length = this->m_priv_host_length;
406407
m_acl_map =
407408
get_global_acl_cache()->checkout_acl_map(this, uid, m_active_roles);
408409
if (m_acl_map != nullptr) {
409-
DBUG_PRINT("info", ("Roles are active and global access for %s@%s is set to"
410-
" %lu",
411-
user().str, host_or_ip().str, m_acl_map->global_acl()));
410+
DBUG_PRINT("info",
411+
("Roles are active and global access for %.*s@%.*s is set to"
412+
" %lu",
413+
(int)m_priv_user_length, m_priv_user, (int)m_priv_host_length,
414+
m_priv_host, m_acl_map->global_acl()));
412415
set_master_access(m_acl_map->global_acl(), m_acl_map->restrictions());
413416
} else {
414417
set_master_access(0);

0 commit comments

Comments
 (0)