FrankChen021 commented on code in PR #19432:
URL: https://github.com/apache/druid/pull/19432#discussion_r3208906497


##########
extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authentication/validator/LDAPCredentialsValidator.java:
##########
@@ -237,22 +243,92 @@ SearchResult getLdapUserObject(BasicAuthLDAPConfig 
ldapConfig, DirContext contex
           ldapConfig.getBaseDn(),
           StringUtils.format(ldapConfig.getUserSearch(), encodedUsername),
           sc);
+      final SearchResult userResult;
       try {
         if (!results.hasMore()) {
           return null;
         }
-        return results.next();
+        userResult = results.next();
       }
       finally {
         results.close();
       }
+
+      // Some LDAP servers do not return memberOf in search results. When 
memberOf is
+      // absent and group search configuration is provided, fall back to a 
reverse
+      // group lookup.
+      if (ldapConfig.isGroupSearchConfigured() && 
!hasMemberOfAttribute(userResult)) {

Review Comment:
   [P2] Reverse group lookup runs before password verification
   
   getLdapUserObject now performs the configured subtree group search before 
validatePassword is called. With reverse lookup enabled, any unauthenticated 
request for an existing user whose search result lacks memberOf can force this 
extra LDAP group search even when the password is wrong, amplifying brute-force 
attempts into expensive LDAP/Druid load. Please do the reverse group lookup 
only after the user bind succeeds, or split lookup/enrichment so failed 
credentials do not trigger group enumeration.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to