Skip to content

Commit a57c62e

Browse files
harinvadodariadahlerlend
authored andcommitted
Bug#31430086: USER CAN ESCALATE PRIVILEGES USING SET PASSWORD COMMAND TO DROP ALL PARTIAL REVOKES
Description: A subclass of ACL DDLs can potentially update in-memory structures that manages partial revokes in incorrect manner. Fix: In-memory updates for partial revokes structures should be conditional. Only when partial revokes are truely updated, these structures need updates. This patch also covers fix for an issue in RENAME USER when partial revokes are present. RB: 24567
1 parent 65f02de commit a57c62e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

sql/auth/sql_auth_cache.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,11 @@ void acl_update_user(const char *user, const char *host, enum SSL_type ssl_type,
26772677
("Updates global privilege for %s@%s to %lu", acl_user->user,
26782678
acl_user->host.get_host(), privileges));
26792679
acl_user->access = privileges;
2680+
if (what_to_update.m_what & USER_ATTRIBUTES &&
2681+
(what_to_update.m_user_attributes &
2682+
acl_table::USER_ATTRIBUTE_RESTRICTIONS))
2683+
acl_restrictions->upsert_restrictions(acl_user, restrictions);
2684+
26802685
if (mqh->specified_limits & USER_RESOURCES::QUERIES_PER_HOUR)
26812686
acl_user->user_resource.questions = mqh->questions;
26822687
if (mqh->specified_limits & USER_RESOURCES::UPDATES_PER_HOUR)
@@ -2757,7 +2762,6 @@ void acl_update_user(const char *user, const char *host, enum SSL_type ssl_type,
27572762
acl_user->password_require_current =
27582763
password_life.update_password_require_current;
27592764
}
2760-
acl_restrictions->upsert_restrictions(acl_user, restrictions);
27612765

27622766
/* search complete: */
27632767
break;

sql/auth/sql_user.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,8 +1754,11 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
17541754
*/
17551755
idx--;
17561756
} else if (user_to) {
1757+
auto restrictions = acl_restrictions->find_restrictions(acl_user);
1758+
acl_restrictions->remove_restrictions(acl_user);
17571759
acl_user->set_user(&global_acl_memory, user_to->user.str);
17581760
acl_user->set_host(&global_acl_memory, user_to->host.str);
1761+
acl_restrictions->upsert_restrictions(acl_user, restrictions);
17591762

17601763
rebuild_cached_acl_users_for_name();
17611764
} else {

0 commit comments

Comments
 (0)