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

Use constant-time comparison when validating the server certificate fingerprint

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 3.4.3, 3.5.9
    • Other
    • None

    Description

      In the MitM-proof authentication path, the driver derives the expected validation hash (SHA-256 over the user's hashed password, the scramble, and the captured certificate fingerprint) and compares it against the value supplied by the server. The comparison used String.equals: return hashHex.equals(serverValidationHex);

      String.equals is not constant-time: it returns early on a length mismatch and on the first differing character, so the execution time depends on the length of the matching prefix.

      Because the server-supplied value is attacker-influenceable, this is a timing side-channel — an attacker able to measure the client's accept/reject timing could, in principle, recover the expected hash byte by byte and forge a valid server proof.

      correction :
      Compare with a constant-time routine that does not short-circuit:

      return MessageDigest.isEqual(
      hashHex.getBytes(StandardCharsets.US_ASCII),
      serverValidationHex.getBytes(StandardCharsets.US_ASCII));

      thanks jmestwa-coder for report and PR : https://github.com/mariadb-corporation/mariadb-connector-j/pull/224

      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.