-
Notifications
You must be signed in to change notification settings - Fork 13.8k
harden: the ldap manager in the enterprise edition modu... in Manager.ts #41791
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { Abac, Team } from '@rocket.chat/core-services'; | |||||||||||||||||||||||||||
| import type { ILDAPEntry, IUser, IRoom, IRole, IImportUser, IImportRecord } from '@rocket.chat/core-typings'; | ||||||||||||||||||||||||||||
| import { License } from '@rocket.chat/license'; | ||||||||||||||||||||||||||||
| import { Users, Roles, Subscriptions as SubscriptionsRaw, Rooms } from '@rocket.chat/models'; | ||||||||||||||||||||||||||||
| import ldapEscape from 'ldap-escape'; | ||||||||||||||||||||||||||||
| import type ldapjs from 'ldapjs'; | ||||||||||||||||||||||||||||
| import type { FindCursor } from 'mongodb'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -297,9 +298,9 @@ export class LDAPEEManager extends LDAPManager { | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| const searchOptions: ldapjs.SearchOptions = { | ||||||||||||||||||||||||||||
| filter: filter | ||||||||||||||||||||||||||||
| .replace(/#{username}/g, username) | ||||||||||||||||||||||||||||
| .replace(/#{groupName}/g, groupName) | ||||||||||||||||||||||||||||
| .replace(/#{userdn}/g, dn.replace(/\\/g, '\\5c')), | ||||||||||||||||||||||||||||
| .replace(/#{username}/g, ldapEscape.filter`${username}`) | ||||||||||||||||||||||||||||
| .replace(/#{groupName}/g, ldapEscape.filter`${groupName}`) | ||||||||||||||||||||||||||||
| .replace(/#{userdn}/g, ldapEscape.filter`${dn}`), | ||||||||||||||||||||||||||||
|
Comment on lines
+301
to
+303
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: When a substituted value contains JavaScript replacement tokens such as Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||
| scope: 'sub', | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: RocketChat/Rocket.Chat
Length of output: 9986
🏁 Script executed:
Repository: RocketChat/Rocket.Chat
Length of output: 27697
Use one callback-based replacement.
String.prototype.replacetreats$&,$`` and$'as replacement tokens. LDAP filter escaping does not escape these JavaScript tokens. A craftedusername,groupName, ordn` can alter the generated filter. Sequential replacements can also reinterpret placeholder text inside an earlier value.Replace all placeholders in one pass with a function replacer. Add regression cases for these replacement tokens and for values containing
#{groupName}or#{userdn}.🤖 Prompt for AI Agents