[MDEV-25126] PAMv2 plugin files does not have correct permissions Created: 2021-03-12 Updated: 2021-09-20 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Packaging, Plugin - pam, Server |
| Affects Version/s: | 10.5.9 |
| Fix Version/s: | 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Michal Schorm | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
RHEL 8; MariaDB upstream RPMs |
||
| Description |
|
The directory
and the SUID-to-root binary
do not have correct permissions. The current permissions are: The directory permissions allows an unprivileged user 'mysql' to tamper with the SUID-to-root binary inside the directory. Following facts should be taken in consideration: 1/ 2/ Is such use-case expected or supported ? I guess no one complained yet, so the more restrictive approach is probably fine. 3/ There is probably no need to have the restriction on both the directory and the binary. Conclusion: If restriction to other users was NOT intended, I'd go with: Else if restriction was intended, I'd go preferably with: Or Rather than: But NOT the current: What is the opinion of @otto as for Debian packaging ? While we are talking about PAMv2 plugin, I agree that MDEV-23628 might deserve a better error message. |
| Comments |
| Comment by Sergei Golubchik [ 2021-03-12 ] | |||
|
The goal is to have a suid-root binary that only mysql user can execute. It is very intentional that other users should not be able to access it, otherwise they would be able to use it to brute-force passwords. You suggest to limit the access to mysql group, not to mysql user. I'm unsure of consequences, if it would potentially allow more users to run the tool, it would allow them to brute-force OS passwords. Who can have access to mysql group, some admin performing a backup? otto, FYI | |||
| Comment by Otto Kekäläinen [ 2021-03-13 ] | |||
|
Status in Debian packaging:
My original suggestion was to have this auth pam tool as a separate plugin to limit the consequences of a potential vulnerability to only those systems that have it installed (99% of systems don't use this at all). After discussion with Serg it was decided to keep it by default (as the plugin size is so small) but I rewrote and documented it better in https://github.com/MariaDB/server/blob/10.6/debian/mariadb-server-10.6.postinst#L137-L154 Going with ` However, let's think about this a bit and not do hasty changes. | |||
| Comment by Daniel Black [ 2021-03-14 ] | |||
|
or to restrict to mysql user and not have write permissions on directory: directory mysql:mysql 500 | |||
| Comment by Michal Schorm [ 2021-03-14 ] | |||
|
Thank you for the explanation Sergei. Now that I see the problematic, I understand that my proposal is (mostly) wrong. I agree that we surely shouldn't be hasty about it, just as Otto says. Taking any permission from the file / directory owner does not add much security, as the owner can always change all of the permissions on his files. I stumbled upon this issue when introducing PAMv2 plugin to RHEL. I opened this ticket in a hope we can come to some universal upstream solution. It might not be the case for now, but the discussion already broaden my horizons. | |||
| Comment by Michal Schorm [ 2021-03-20 ] | |||
|
I solved the issue the best I could for now on the downstream side. I set following permissions: And I moved the PAM plugins and files to a separate sub-package "mariadb-pam", which is suggested by the server ( = NOT installed by default with the server) The issue with anyone (else) in 'mysql' group having unrestricted access to the binary remain unsolved, yet minimised - I believe. Isn't there any timeout, implemented in PAM (or the unix_chkpwd), which would slow down the attacker? It is a common way to slow down brute-force attacks, implementing some sleep time before the credentials are evaluated. | |||
| Comment by Sergei Golubchik [ 2021-03-24 ] | |||
|
Can you clarify the main problem you're solving here:
Tamper how? What can a mysql user do? A user can rename or delete it, losing suid rights. I don't see how a user can modify it to get additional access under suid. | |||
| Comment by Otto Kekäläinen [ 2021-05-24 ] | |||
It seems Fedora now went ahead and split this into a separate plugin. Maybe we should follow suit in upstream RPM packaging and in upstream/downstream Debian packaging as well? Having many different versions of a solution for the same problem can cause excess overhead and more problems. https://src.fedoraproject.org/rpms/mariadb/c/51cd6d3ae2be8c6fc5b495238569107cd3eb2b67?branch=rawhide |