Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-1326

Unsafe escaping in enquoteLiteral()/enquoteNCharLiteral()

    XMLWordPrintable

Details

    Description

      SQL injection in new JDBC 4.3 enquoteLiteral() and enquoteNCharLiteral()

      Both methods fail to safely quote values, allowing input to break out of the literal:

      enquoteLiteral emits ' as \' (via Matcher.appendReplacement, which collapses the doubled backslash). Under NO_BACKSLASH_ESCAPES the backslash isn't an escape, so the quote closes the string early.
      Backslashes are left undoubled, so a trailing \ escapes the closing quote under the default sql_mode. enquoteNCharLiteral never escapes backslashes at all.

      Repro:

      Driver.enquoteLiteral("x' OR '1'='1");  // → 'x\' OR \'1\'=\'1'  (injection under NO_BACKSLASH_ESCAPES)
      Driver.enquoteLiteral("a\\");           // → 'a\'  (literal stays open under default mode)
      

      thanks jmestwa-coder for PR https://github.com/mariadb-corporation/mariadb-connector-j/pull/228/changes

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            diego dupin Diego Dupin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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