+An LDAP distinguished name (DN) identifies an entry in a directory, for example
+uid=alice,ou=people,dc=example,dc=com. When an authentication framework
+builds the bind DN by concatenating the login principal into a DN template without
+escaping it for RFC 2253, an attacker can supply DN metacharacters
+(, + " \ < > ; =, a leading #, or leading/trailing
+whitespace) to change the structure of the DN that is used to authenticate. Depending
+on the directory, this can bypass authentication or impersonate another principal.
+
+This query targets the defect inside an authentication library or framework
+(Apache Shiro, a custom Spring Security realm, a CAS or pac4j SPI, a Keycloak provider),
+where the login principal does not arrive at a remote flow source such as a servlet
+parameter, but as a method parameter at the library boundary. The supported
+java/ldap-injection query, which starts from remote flow sources, does not
+report on such a framework because there is no remote flow source to start from.
+
+The DN escape set (RFC 2253) differs from the LDAP search-filter escape set (RFC 4515).
+A value escaped for a search filter (for example with LdapEncoder.filterEncode)
+is still unsafe in a DN, and vice versa. This query treats only DN escapers as
+sanitizers.
+
+The library-mode source model is name-heuristic: it treats the login-principal
+accessors of common authentication frameworks, and the string parameters of
+DN-builder-shaped methods (for example getUserDn or
+getUsernameWithSuffix), as sources. This is a deliberate
+precision/recall trade for the library case, where there is no remote flow source to
+anchor on. A framework that builds the DN in a differently named helper is missed, and
+a benign method that matches the name pattern may produce a false positive; this is why
+the query is experimental and uses medium precision. Triage a result by confirming the
+value reaches a real bind sink unescaped.
+
+Escape the login principal for RFC 2253 before placing it in a DN, for example with
+javax.naming.ldap.Rdn.escapeValue, Spring LDAP
+LdapEncoder.nameEncode, or OWASP ESAPI encodeForDN. Prefer
+building the DN from structured components (an LdapName and
+Rdn objects) rather than string concatenation.
+
+The following example concatenates the login principal into the bind DN with no
+escaping. An attacker who logs in as * or
+admin,ou=admins,dc=example,dc=com+uid=anything can manipulate the DN.
+
+The following example escapes the principal with Rdn.escapeValue before
+building the DN, so DN metacharacters are neutralised.
+