Details
Description
This is a common path to an arbitrary code execution:
- create a plugin or a udf with SELECT ... INTO DUMPFILE
- load it with INSTALL PLUGIN or CREATE FUNCTION
This requires certain prerequisites:
- the attacker must have FILE privilege to create a file
- the attacker must have SUPER or INSERT on mysql.plugin or mysql.func tables
- plugin-dir path must be within secure-file-priv path
- plugin-dir must be writable by mysql user.
the last item should basically never be the case, so the above is not a bona fide security vulnerability but a case of a misconfigured server. It's a known for many years issue, it's documented (for plugin-dir — must not be writable by the server), still it keeps being reported over and over.
Let's harden the server against thusly misconfigured server. CREATE FUNCTION / INSTALL PLUGIN can refuse loading a writable .so file. As SELECT ... DUMPFILE always create a writable file, this will make the above scenario impossible. Writable means owned by geteuid() and a -w-------- permission bit is set by SELECT ... DUMPFILE not an actual ability to write — everything is "writable" for root, but if the bit isn't set then the file wasn't created by SELECT ... DUMPFILE.
Note, that this needs an additional packaging fix, to package plugins as chmod 0444 otherwise mariadbd may refuse to load them (in locally installed binary tarballs or when run as root)
Attachments
Issue Links
- relates to
-
MDEV-27038 Custom configuration file procedure does not work with Docker Desktop for Windows 10+
-
- Closed
-