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

UNION converts NULL returned by AES_ENCRYPT with an invalid mode to an empty string in non-strict SQL mode

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8.9
    • 11.4
    • Encryption
    • Linux x86_64, MariaDB 11.8.9 binary distribution
    • Unexpected results

    Description

      In non-strict SQL mode, AES_ENCRYPT() with an invalid encryption mode returns NULL in a SELECT DISTINCT query, but an equivalent UNION query returns an empty binary string.

      The difference reproduces using the native mariadb command-line client. No tables are required.

      Reproducer:

      SET SESSION sql_mode = '';
       
      SELECT DISTINCT AES_ENCRYPT('x', 'k', '', 'hkdf') AS col1;
       
      SELECT AES_ENCRYPT('x', 'k', '', 'hkdf') AS col1
      UNION
      SELECT AES_ENCRYPT('x', 'k', '', 'hkdf') AS col1;
      

      Actual result on 11.8.9-MariaDB:

      The SELECT DISTINCT query returns one row containing NULL:

      col1
      NULL
      

      The UNION query returns one row containing an empty binary string instead of NULL.

      In MariaDB, the fourth argument of AES_ENCRYPT() specifies the encryption mode. Although 'hkdf' is not a valid encryption mode, using the same fixed arguments in equivalent SELECT DISTINCT and UNION queries should not change NULL into an empty string.

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            jxgui jinxingui
            Oleksandr Byelkin Oleksandr Byelkin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 0d
                0d
                Remaining:
                Remaining Estimate - 3h
                3h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Git Integration

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