Following an LDAP referral sends the configured bind credentials to the referral's target server, which can be any host · Issue #55764 · keycloak/keycloak · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Following an LDAP referral sends the configured bind credentials to the referral's target server, which can be any host #55764
When an LDAP user federation provider has Referral set to follow, Keycloak follows any ldap:// or ldaps:// referral that the configured LDAP server returns during a search. It then reconnects to the host named in the referral using the same bind DN and bind credential configured for the trusted LDAP server. Keycloak checks only the referral URL's scheme and never compares the referral's host with the configured server. As a result, the service account's bind credentials can be sent, as a simple bind, to any host that Keycloak can reach over the network.
This can be triggered in two ways:
A man-in-the-middle on an ldap:// connection without StartTLS can inject a referral that sends the credentials to a collector host.
A compromised or partially trusted LDAP server, or anyone who can write a referral entry within the search scope Keycloak queries, can return a referral that harvests the credentials or relays them to internal hosts reachable from the Keycloak server.
The hardening for CVE-2025-13467 (#44993) limits followed referrals to ldap/ldaps URLs. That fix works as intended. It does not cover this case, because the leak happens on the plain LDAP URL path that it still allows.
When following a referral, Keycloak sends the configured bind credentials only to the configured LDAP server or to hosts the administrator has explicitly trusted. A referral to any other host is either not followed or followed without the service account's bind credentials.
Actual behavior
When Referral is follow, any referral the configured LDAP server returns causes Keycloak to send the service account's bind DN and password to the referral's target host. This happens no matter which host the referral names. A host that the administrator never configured receives the federation service account's credentials. These are usually a privileged LDAP/AD service account's credentials, and with them that host can read or modify the federated directory.
Acknowledgement
Thank you to HocVoNgThai for reporting this issue. As following referrals is an opt-in setting and both exploitation paths require an untrusted network path to, or a compromise of, the administrator-configured LDAP server, this is considered a weakness and handled publicly.
This issue was originally tracked in the private repository. Migrated by @ssilvert.
Activity