Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25752

A password stored in clear text can no longer be checked once its property uses the Hash storage type

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Problem

      Since XWIKI-24357, a password value stored in clear text can no longer be checked when the password property it belongs to uses the Hash storage type. PasswordClass#arePasswordsMatching throws:

      java.lang.IllegalArgumentException: The provided encoded password doesn't match any known hash encoded password format.
      

      A property can hold clear values with the Hash storage type when it used the Clear storage type at the time the values were saved, and was switched to Hash afterwards (from the class editor, or by an extension changing the definition of its class). Switching the storage type doesn't change the values already stored.

      Before XWIKI-24357, such a value was compared in clear, so it kept working: getEquivalentPassword returned the given password unchanged when the stored value didn't start with hash:. Now any feature checking it fails. For example, OIDC-334: the OIDC provider userinfo endpoint answers with an HTTP 500 error page containing this exception.

      Steps to reproduce

      1. Create a class with a password property secret whose storage type is Clear.
      2. Add an object of that class to a page and set secret to mysecret.
      3. Edit the class and switch the storage type of secret to Hash.
      4. Check the stored value, e.g. with $doc.getObject('<class>').getXObject().isPasswordValueMatching('secret', 'mysecret') from a script with programming right.

      Expected: true, as before XWIKI-24357.
      Actual: IllegalArgumentException: The provided encoded password doesn't match any known hash encoded password format.

      Proposed fix

      When the storage type is Hash and the stored value doesn't look like a hash at all (no hash: prefix and no algorithm prefix between braces), compare it in clear and log a warning saying that the value should be hashed or reset. A value which looks like a hash but uses an unknown format keeps failing, so that a stored hash is never accepted as the password itself.

      This only restores the possibility to check such values. Handling the existing values when the storage type of a property changes is a separate topic.

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: