Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not try to drop roles in mysql hardening #649

Merged
merged 34 commits into from Nov 12, 2023
Merged

do not try to drop roles in mysql hardening #649

merged 34 commits into from Nov 12, 2023

Conversation

rndmh3ro
Copy link
Member

@rndmh3ro rndmh3ro commented Mar 8, 2023

There's a new feature in mariadb 10.1 (https://mariadb.org/grant-to-public-in-mariadb/) and mysql 8 (need to verify).

MariaDB has quite a complex privilege system. Most of it is based on the SQL Standard spec; however we do have some specific MariaDB extensions. GRANT ... TO PUBLIC (MDEV-5215) is a standard feature that is now available as a preview in MariaDB 10.11.0. It is related to ROLES and DEFAULT ROLE, but it covers a different use case.

ROLES are effectively “privilege packages” that you can enable and disable as a user. One can also set which “privilege package” will be enabled at connect time by setting a DEFAULT ROLE per user. This is all quite useful, however it is missing one key feature. For a DBA, it would be quite useful to state only once that all users need to have a certain set of privileges. This is where GRANT ... TO PUBLIC comes in.

Some more information here: https://mariadb.org/wp-content/uploads/2018/07/MariaDB-Roles-Tampere-Unconference-2018.pdf

This role is shown as a user, it has however a new is_role-flag.

MariaDB [(none)]> select user, host, is_role from mysql.user; +-----------------------+-----------+---------+
| User                  | Host      | is_role |
+-----------------------+-----------+---------+
| mariadb.sys           | localhost | N       |
| root                  | localhost | N       |
| mysql                 | localhost | N       |
| PUBLIC                |           | Y       |
| monitoring            | %         | N       |
| monitoring            | localhost | N       |
| galera_mariadb_backup | %         | N       |
+-----------------------+-----------+---------+

Since this "user" does not have a password or authentication_string, the ansible-role tries to delete it but fails.

Sebastian Gumprich and others added 27 commits November 11, 2023 15:34
There's a new feature in mariadb 10.1 (https://mariadb.org/grant-to-public-in-mariadb/) and mysql 8 (need to verify).

    MariaDB has quite a complex privilege system. Most of it is based on the SQL Standard spec; however we do have some specific MariaDB extensions. GRANT ... TO PUBLIC (MDEV-5215) is a standard feature that is now available as a preview in MariaDB 10.11.0. It is related to ROLES and DEFAULT ROLE, but it covers a different use case.

    ROLES are effectively “privilege packages” that you can enable and disable as a user. One can also set which “privilege package” will be enabled at connect time by setting a DEFAULT ROLE per user. This is all quite useful, however it is missing one key feature. For a DBA, it would be quite useful to state only once that all users need to have a certain set of privileges. This is where GRANT ... TO PUBLIC comes in.

Some more information here: https://mariadb.org/wp-content/uploads/2018/07/MariaDB-Roles-Tampere-Unconference-2018.pdf

This role is shown as a user, it has however a new is_role-flag.

MariaDB [(none)]> select user, host, is_role from mysql.user;
+-----------------------+-----------+---------+
| User                  | Host      | is_role |
+-----------------------+-----------+---------+
| mariadb.sys           | localhost | N       |
| root                  | localhost | N       |
| mysql                 | localhost | N       |
| PUBLIC                |           | Y       |
| monitoring            | %         | N       |
| monitoring            | localhost | N       |
| galera_mariadb_backup | %         | N       |
+-----------------------+-----------+---------+

Since this "user" does not have a password or authentication_string, the ansible-role tries to delete it but fails.

Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Sebastian Gumprich <sebastian.gumprich@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
@schurzi schurzi marked this pull request as ready for review November 11, 2023 14:46
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Copy link
Member Author

@rndmh3ro rndmh3ro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally! Thanks @schurzi!

I can't approcve this PR since mine, but after adding some comments to the temp. task, let's merge this.

.github/workflows/mysql_hardening.yml Show resolved Hide resolved
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
@schurzi schurzi merged commit eac33e8 into master Nov 12, 2023
18 checks passed
@schurzi schurzi deleted the mysql_roles branch November 12, 2023 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants