Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Deactivated users gets activated after Background LDAP Sync #17561

Closed
ankar84 opened this issue May 7, 2020 · 8 comments · Fixed by #17645
Closed

[BUG] Deactivated users gets activated after Background LDAP Sync #17561

ankar84 opened this issue May 7, 2020 · 8 comments · Fixed by #17645
Assignees

Comments

@ankar84
Copy link

ankar84 commented May 7, 2020

Description:

Our users are imported to Rocket.Chat from our corporate LDAP server.
When user leave organization his LDAP account is disabled and script like this is deactivating Rocket.Chat account for that user.
After upgrade to 3.1.1 I see, that deactivated users in past are activated now. It's a security bug.
I think that such activating of deactivated users is a result of Background LDAP Sync (scheduled one a day for our deployment)

Steps to reproduce:

  1. Deactivate user manualy or by API with such script
  2. Wait Background LDAP Sync finished
  3. Check deactivated user status

Expected behavior:

Disabled in LDAP accounts should remain deactivated while Background LDAP Sync

Actual behavior:

All deactivated users become activated after Background LDAP Sync
image

Server Setup Information:

  • Version of Rocket.Chat Server: 3.1.1
  • Operating System: CentOS7
  • Deployment Method: docker
  • Number of Running Instances: 12
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: v12.16.1
  • MongoDB Version: 4.0.17
@bbrauns
Copy link
Contributor

bbrauns commented May 7, 2020

Thank you for reporting, we have exactly the same problem. A custom bash script is triggered by our identity management system when a user has left the company. The script deactivates the rocket.chat user account but the next day he/she is reactivated...So at the moment it is not possible to completely deny access for old or abusive user accounts besides deletion.

@ankar84
Copy link
Author

ankar84 commented May 7, 2020

So at the moment it is not possible to completely deny access for old or abusive user accounts besides deletion.

Definitely!
But for us it's a bit not so serious. We use KeyCloack to authenticate users.
Both LDAP users import and KeyCloack are limited by one LDAP security group.
After user disabled in LDAP, that user also removed from security group and KeyClock authentication will not be successful.
Anyway it still important security issue.

@magikmw
Copy link

magikmw commented May 11, 2020

I've just encountered this issue after upgrading to 3.2.2 from 3.0.7. This is really bad, especially since deactivated accounts will become reactivated again after the next sync.
Also related #7235 since if the LDAP/AD account is disabled it should also deactivate RC account.
How did this issue go 5 days without triage? Sorry about that. Uncalled for.

Edit:

  • Also, rocket now syncs and reactivates users that not only are not active in LDAP/AD, but also out of the OU and group the filter looks for in LDAP users

@magikmw
Copy link

magikmw commented May 11, 2020

I did some digging, and I'm fairly sure this PR introduced the bug #16671

Either of these seem like the main culprit since the rest of the PR is just moving code around:

({ BaseDN, options } = callbacks.run('ldap.beforeSearchAll', { BaseDN, options }));

({ BaseDN, options } = callbacks.run('ldap.beforeSearchAll', { BaseDN, options }));

This one seems to be the most likely one:
callbacks.run('ldap.afterSyncExistentUser', { ldapUser, user });

I'm almost confident this bug was present before, as there doesn't seem to be any check for filters or ldap status of the user in sync(). It's just that this PR fixed the existent user sync not working, revealing this bug here.

I'd try a PR, but I'm not feeling up to the task with my JS skills and uncertainty of the codebase.

Ping @rodrigok @sampaiodiego

@mdanovz
Copy link

mdanovz commented May 12, 2020

Yeah. We have the same bug. After upgrading server from 2.4.1 to 3.2.1, all deactivated users were activated.
And on their mobiles push notifications began to come.
After half a year of chat irrelevance.

@rodrigok
Copy link
Member

Thanks for the report, we are investigating this.

@ankar84
Copy link
Author

ankar84 commented May 27, 2020

  • Also, rocket now syncs and reactivates users that not only are not active in LDAP/AD, but also out of the OU and group the filter looks for in LDAP users

That is really bad for us.

@GJKrupa
Copy link

GJKrupa commented Jun 18, 2020

I have the opposite problem. We have a bot user that's enabled in AD but keeps getting deactivated every time a background sync is run. It's in a sub-OU under the user root. We're running 3.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants