Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-42377

refuse loading writeable plugin files

    XMLWordPrintable

Details

    • New Feature
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3
    • 10.11, 11.4, 11.8, 12.3
    • Plugins
    • None

    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

          Activity

            People

              serg Sergei Golubchik
              serg Sergei Golubchik
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.