ldapsdk icon indicating copy to clipboard operation
ldapsdk copied to clipboard

processSync in SimpleBindRequest allows empty password with set bindDN

Open sshkel opened this issue 6 years ago • 4 comments

Hey folks, Is there a reason why check for empty password when bindDN is set comes after logic for doing processing in synchronous mode? https://github.com/pingidentity/ldapsdk/blob/master/src/com/unboundid/ldap/sdk/SimpleBindRequest.java#L513

protected BindResult process(final LDAPConnection connection, final int depth)
            throws LDAPException
  {
    if (connection.synchronousMode())
    {
      @SuppressWarnings("deprecation")
      final boolean autoReconnect =
           connection.getConnectionOptions().autoReconnect();
      return processSync(connection, autoReconnect);
    }

    // See if a bind DN was provided without a password.  If that is the case
    // and this should not be allowed, then throw an exception.
    if (password != null)
    {
      if ((bindDN.getValue().length > 0) && (password.getValue().length == 0) &&
           connection.getConnectionOptions().bindWithDNRequiresPassword())
      {
        final LDAPException le = new LDAPException(ResultCode.PARAM_ERROR,
             ERR_SIMPLE_BIND_DN_WITHOUT_PASSWORD.get());
        debugCodingError(le);
        throw le;
      }
    }
// Async stuff

At the moment that check only applies to async mode and leaves synchronous mode open to the old and nasty behaviour. Could that entire block be moved up to cover both sync and async methods?

sshkel avatar Mar 09 '18 14:03 sshkel

Thank you very much for pointing this out. It is a bug, and I've just committed a fix (https://github.com/pingidentity/ldapsdk/commit/8471904a02438c03965d21367890276bc25fa5a6) for it.

dirmgr avatar Mar 09 '18 17:03 dirmgr

Wicked, thanks heaps for hotfixing

sshkel avatar Mar 10 '18 01:03 sshkel

I have just published the 4.0.5 release of the LDAP SDK, which contains the fix for this issue. I also wrote a blog post at https://nawilson.com/2018/03/19/cve-2018-1000134-and-the-unboundid-ldap-sdk-for-java/ that describes it in detail.

dirmgr avatar Mar 19 '18 10:03 dirmgr

Thanks Neil. Appreciate it, very good article

sshkel avatar Mar 20 '18 02:03 sshkel