Summary
n8n's LDAP authentication flow previously auto-linked LDAP identities to existing local accounts solely based on matching email addresses.
An LDAP-authenticated user who could modify their own LDAP email attribute could set it to another user's email, including an administrator's, and gain persistent access to that account even after reverting the LDAP email.
Affected context
This vulnerability affects n8n deployments that:
- Have LDAP authentication explicitly configured and enabled (non-default), and
- Allow user-controllable LDAP attributes for email, and
- Maintain both local n8n user accounts and LDAP-backed identities.
In this context, n8n trusted the LDAP email attribute as a unique link key for associating identities, without enforcing additional verification or ownership checks.
Exploit preconditions
- Attack surface: n8n web interface using LDAP login.
- Required access: Valid LDAP credentials for any account in the directory.
- Additional capability: Ability for the attacker to modify their own LDAP email attribute (e.g., through a self-service portal or overly permissive directory ACLs).
- Trigger point: Logging into n8n via LDAP after setting the LDAP email to match the target n8n user's email address.
- Why exploitation is possible: The application implicitly trusted the LDAP email attribute as sufficient proof of identity and automatically linked the LDAP user to an existing local account with the same email, without additional confirmation or ownership validation. The linkage persisted beyond changes to the LDAP email.
Why this happens
The core issue is an improper authentication and identity binding design (CWE-287) where n8n:
- Treated a single, mutable attribute (email) as a stable, unique identifier across systems.
- Automatically linked LDAP identities to existing local accounts purely on email equality.
- Did not verify that the LDAP principal actually owned or originally created the local account associated with that email.
Because some directory configurations allow users to change their own email attribute, a malicious user could impersonate another account at the identity-linking stage. Once the linkage was created, it was not revalidated on subsequent logins, leading to a persistent account takeover even after the LDAP email was changed back.
Potential impact
- Full compromise of another user's n8n account, including administrators.
- Unauthorized access to workflows, credentials, integrations, and automation secrets stored in the compromised account.
- Escalation from a low-privilege LDAP user to an administrative role within n8n.
- Manipulation or deletion of workflows, resulting in business process disruption.
- Indirect access to connected systems and APIs through compromised workflow credentials.
General mitigation guidance
Mitigation generally focuses on stronger identity binding and safer use of external authentication attributes:
- Avoid using mutable, user-controlled attributes (like email) as the sole key for linking external identities to local accounts.
- Prefer stable, non-user-editable identifiers from the identity provider (e.g., immutable directory IDs) as the primary linkage key.
- Require explicit, verified account linking flows (e.g., out-of-band confirmation or admin approval) instead of automatic linkage on first login.
- Enforce least-privilege in directory configurations so regular users cannot modify identity attributes used for authentication or account mapping.
- Periodically audit identity mappings for anomalies, such as unexpected associations between LDAP identities and privileged local accounts.
- Apply defense-in-depth by restricting what a single compromised n8n account can do, for example through role-based access controls and scoped credentials.
How teams detect issues like this
Potential detection approaches include:
- Log analysis: Monitor authentication and account-linking logs for:
- LDAP logins that result in new linkages to existing local accounts.
- Sudden changes where a low-privilege LDAP user appears associated with an administrator-level n8n account.
- Directory monitoring: Detect unusual patterns of email attribute changes, especially where:
- A user temporarily sets their email to match another known user's address.
- Email changes cluster around times of new n8n account associations.
- Configuration review: Regularly review:
- LDAP schema and ACLs to ensure users cannot modify attributes that are used for identity mapping.
- n8n authentication configuration to confirm that it uses stable, non-mutable identifiers and does not auto-link accounts without verification.
- Automated checks: Use security configuration scanners or CI/CD policy checks to flag unsafe authentication/linking patterns, such as reliance on user-editable attributes for identity binding.

