Add 88 new defect entries to HIGH and MEDIUM tables:
HIGH: mysql-0001/0002, mariadb-0001, redis-0001/0002, valkey-0001/0002, openvpn-0001,
vlc-0001, prometheus-0001, otel-collector-0001, cockroachdb-0001..0004,
tidb-0001..0008, kubernetes-0001/0002, go-0001, kotlin-0002, scala-0001,
allegro5-0001, sdl2-0001, grafana-0001, clickhouse-0001, duckdb-0001,
mongodb-0001, envoy-0001, istio-0001, cilium-0001, linkerd2-0001,
linux-0001/0002/0003, tor-0002/0003, curl-0001, julia-0001, lua-0001,
perl5-0001, nats-0001, spring-0003/0004, tomcat-0001, onos-0002, odl-0002
MEDIUM: helm-0001, mariadb-0002, openssl-0001/0002, memcached-0001,
cassandra-0001..0004, flink-0001, storm-0001/0002, zookeeper-0001..0003,
pip-0001, gradle-0001, nginx-0001, haproxy-0001, caddy-0001, varnish-0001,
ffmpeg-0001, gstreamer-0001, raylib-0001, love2d-0001, php-0001/0002,
r-source-0001, cpython-0002, ruby-0001, rabbitmq-0003/0004, activemq-0001,
ovs-0001, onos-0003, odl-0002, jetty-0001
PDF: 976K
46 lines
2.1 KiB
Diff
46 lines
2.1 KiB
Diff
--- a/sql/auth/sql_authorization.cc
|
|
+++ b/sql/auth/sql_authorization.cc
|
|
@@ -4875,16 +4875,26 @@ mysql_show_grants(THD *thd, LEX_USER *lex_user,
|
|
if (have_using_clause) {
|
|
std::vector<Role_id> mandatory_roles;
|
|
get_mandatory_roles(&mandatory_roles);
|
|
List_of_granted_roles granted_roles;
|
|
get_granted_roles(lex_user, &granted_roles);
|
|
- for (auto &role_ref : using_roles) {
|
|
- std::string authid(create_authid_str_from(role_ref));
|
|
- if (find(granted_roles.begin(), granted_roles.end(), authid) ==
|
|
- granted_roles.end()) {
|
|
- if (std::find_if(mandatory_roles.begin(), mandatory_roles.end(),
|
|
- [&](const Role_id &id) -> bool {
|
|
- std::string id_str, rid_str;
|
|
- id.auth_str(&id_str);
|
|
- Role_id rid(role_ref.first, role_ref.second);
|
|
- rid.auth_str(&rid_str);
|
|
- return (Role_id(role_ref.first, role_ref.second) ==
|
|
- id);
|
|
- }) == mandatory_roles.end()) {
|
|
+ // CWE-407 fix (mysql-0001): build O(1) lookup sets before the loop so
|
|
+ // membership checks are not O(G) and O(M) per using_role element.
|
|
+ std::unordered_set<std::string> granted_set;
|
|
+ for (const auto &gr : granted_roles) {
|
|
+ granted_set.insert(gr.first); // gr.first is the authid string
|
|
+ }
|
|
+ std::unordered_set<std::string> mandatory_set;
|
|
+ for (const auto &rid : mandatory_roles) {
|
|
+ std::string s;
|
|
+ rid.auth_str(&s);
|
|
+ mandatory_set.insert(s);
|
|
+ }
|
|
+ for (auto &role_ref : using_roles) {
|
|
+ std::string authid(create_authid_str_from(role_ref));
|
|
+ if (granted_set.find(authid) == granted_set.end()) {
|
|
+ std::string rid_str;
|
|
+ Role_id(role_ref.first, role_ref.second).auth_str(&rid_str);
|
|
+ if (mandatory_set.find(rid_str) == mandatory_set.end()) {
|
|
my_error(ER_ROLE_NOT_GRANTED, MYF(0), role_ref.first.str,
|
|
role_ref.second.str, lex_user->user.str, lex_user->host.str);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|