core icon indicating copy to clipboard operation
core copied to clipboard

LDAP login produces multiple bind failed messages

Open uka-support opened this issue 12 years ago • 9 comments

If a user logs in using an incorrect password, multiple binds are issued to the server which might trigger anti-bruteforce actions server-side or quickly deplete "allowed wrong password attempts".

Version: OC 6.0.2 LDAP-Server: Windows 2008R2

Log extract:

{"app":"user_ldap","message":"Bind failed: 49: Invalid credentials","level":3,"time":"2014-03-19T14:20:48+00:00"}
{"app":"user_ldap","message":"Bind failed: 49: Invalid credentials","level":3,"time":"2014-03-19T14:20:49+00:00"}
{"app":"core","message":"Login failed: user 'username' , wrong password, IP:set log_authfailip=true in conf","level":2,"time":"2014-03-19T14:20:49+00:00"}

Expected behaviour: There should be exactly one bind request which either succeeds or fails.

uka-support avatar Mar 19 '14 14:03 uka-support

Weird. Sometimes I'm seeing 4 binds followed by three "Connection could not be established" messages (all at the same second), sometimes, I'm seeing only 2 binds as shown above.

uka-support avatar Mar 19 '14 14:03 uka-support

@blizzz

karlitschek avatar Mar 19 '14 14:03 karlitschek

That commit should fix it

RobinMcCorkell avatar Mar 19 '14 16:03 RobinMcCorkell

I will have a look and test the patch, thank you.

blizzz avatar Mar 19 '14 16:03 blizzz

@Xenopathic That patch partly fixes the issue. I'm only getting one bind failed error now, but still something is messed up.

Important note: I have TWO LDAP servers configured, usernames are derived from Active Directory login (sAMAccountname) and are guaranteed to be unique.

Scenario: I'm trying to log in as user A with a wrong password using second LDAP server (I'm basically abusing the login to fill the email preference for the user). First login failed as expected, producing only one message (loglevel was WARN):

{"app":"user_ldap","message":"Bind failed: 49: Invalid credentials","level":3,"time":"2014-03-20T19:01:48+00:00"}
{"app":"core","message":"Login failed: user 'userA' , wrong password, IP:set log_authfailip=true in conf","level":2,"time":"2014-03-20T19:01:48+00:00"}

Afterwards, I tied to log in as user B which failed miserably: (I raised log level to DEBUG before performing the second login attempt)

{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=userB,dc=second,dc=local\n)\n attr mail limit 99999 offset 0","level":1,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_bind","level":0,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_errno","level":0,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_error","level":0,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"Bind failed: 49: Invalid credentials","level":3,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=userB,dc=second,dc=local\n)\n attr  limit 99999 offset 0","level":1,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_control_paged_result","level":0,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"LDAP error Operations error (1) after calling ldap_read","level":0,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"LDAP says no user cn=userB,dc=second,dc=local on second-ldap-server.local","level":0,"time":"2014-03-20T19:02:38+00:00"}
{"app":"core","message":"Login failed: user 'userB' , wrong password, IP:set log_authfailip=true in conf","level":2,"time":"2014-03-20T19:02:38+00:00"}
{"app":"user_ldap","message":"Run background job \"updateGroups\"","level":0,"time":"2014-03-20T19:02:40+00:00"}

Now there seems to be something broken inside ownCloud:

{"app":"user_ldap","message":"getGroups getGroups---1-0","level":0,"time":"2014-03-20T19:02:40+00:00"}
{"app":"user_ldap","message":"getGroups Filter (...redacted filter for first server...)","level":0,"time":"2014-03-20T19:02:40+00:00"}
{"app":"user_ldap","message":"getGroups getGroups---1-0","level":0,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"getGroups Filter (...redacted filter for second server...)","level":0,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"bgJ \"updateGroups\" \u2013 Dealing with known Groups.","level":0,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=somegroup-on-first-server,dc=first,dc=local\n)\n attr objectclass limit 99999 offset 0","level":1,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"LDAP error Decoding error (-4) after calling ldap_control_paged_result","level":0,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=somegroup-on-first-server,dc=first,dc=local\n)\n attr member limit 99999 offset 0","level":1,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=somegroup-on-first-server,dc=first,dc=local\n)\n attr objectclass limit 99999 offset 0","level":1,"time":"2014-03-20T19:02:41+00:00"}
{"app":"user_ldap","message":"LDAP error Decoding error (-4) after calling ldap_control_paged_result","level":0,"time":"2014-03-20T19:02:41+00:00"}

Afterwards I seetwo paged searches for every other group from first server, but these succeed or at least do not report errors, followed by searches for every group from second server with some "attribute entryuuid, nsuniqueid etc. not found" and some "attribute displayname not found".

Now I performed an unsuccessful login on first server to see what happens and compare results (user has already logged in successful before).

{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=userC,dc=first,dc=local\n)\n attr mail limit 99999 offset 0","level":1,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_bind","level":0,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_errno","level":0,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_error","level":0,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"Bind failed: 49: Invalid credentials","level":3,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=userC,dc=first,dc=local\n)\n attr  limit 99999 offset 0","level":1,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_control_paged_result","level":0,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP error Operations error (1) after calling ldap_read","level":0,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP says no user cn=userC,dc=first,dc=local on uka-meissen.local","level":0,"time":"2014-03-20T19:29:32+00:00"}
{"app":"core","message":"Login failed: user 'userC' , wrong password, IP:set log_authfailip=true in conf","level":2,"time":"2014-03-20T19:29:32+00:00"}

Another one on first server (with different user D which did not login before) so we could compare to first attempt produced the same sequence of messages.

Another attempt with the same user D on first server produced some strange messages:

{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_unbind","level":0,"time":"2014-03-20T19:35:05+00:00"}
{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=somedifferentuser,dc=first,dc=local\n)\n attr  limit 99999 offset 0","level":1,"time":"2014-03-20T19:35:06+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:35:06+00:00"}
{"app":"user_ldap","message":"readAttribute: cn=userE,dc=first,dc=local found","level":0,"time":"2014-03-20T19:35:06+00:00"}
{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=userD,dc=first,dc=local\n)\n attr displayname limit 99999 offset 0","level":1,"time":"2014-03-20T19:35:06+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:35:06+00:00"}
{"app":"user_ldap","message":"No DN found for userE on second-server.local","level":0,"time":"2014-03-20T19:35:06+00:00"}

Strange thing is: UserE belongs to first server but has somehow been searched on second one (DN is correct!).

Even stranger, after all these message, a single totally unrelated message pops up:

{"app":"user_ldap","message":"No DN found for userC on second-server.local","level":0,"time":"2014-03-20T19:35:07+00:00"}

It's my own user and I did not try to login at this time. And the user belongs to first server for sure.

I hope this analysis helps. Ask me anything to clarify this. :-)

uka-support avatar Mar 20 '14 19:03 uka-support

Well those are debug messages. The patch removes the unnecessary double bind when the first bind fails, thus reducing the number of attempted logins. Those debug messages are simply showing what OwnCloud is doing to determine a user's credentials are invalid. Perhaps @blizzz could comment further?

RobinMcCorkell avatar Mar 20 '14 20:03 RobinMcCorkell

@uka-support when a log in is attempted, all available LDAP servers are tried until one confirms a successful login. This makes it possible to shift users from one server to the other.

blizzz avatar Mar 21 '14 13:03 blizzz

Note: I'm not talking about fallback server. BTW: the root DNs are different, so users can not be moved between servers.

Still strange things happen - I've seen one of our users fail to login multiple times. But she has the password autocompleted in her browser (boo!)... and this seems to be somehow related to the above problems.

Especially these messages look wrong to me:

{"app":"user_ldap","message":"initializing paged search for  FilterobjectClass=* base Array\n(\n    [0] => cn=userC,dc=first,dc=local\n)\n attr  limit 99999 offset 0","level":1,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP error Invalid credentials (49) after calling ldap_control_paged_result","level":0,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"Ready for a paged search","level":1,"time":"2014-03-20T19:29:32+00:00"}
{"app":"user_ldap","message":"LDAP error Operations error (1) after calling ldap_read","level":0,"time":"2014-03-20T19:29:32+00:00"}

-> there should not be invalid credentials when searching and there should not be an operations error... IMO, but I'm not familiar with the internals of LDAP nor ownCloud's use of it.

uka-support avatar Mar 21 '14 13:03 uka-support

me neither ;)

I found the issue, PR coming

blizzz avatar Mar 21 '14 14:03 blizzz