CVE-2026-59368
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
Spring LDAP is a library to simplify LDAP programming in Java, built on the same principles as Spring JDBC. Its LdapQueryBuilder provides a fluent API for building LDAP search queries, including the search base, scope and filter.
An authorization bypass vulnerability (CVE-2026-59368) has been identified in Spring LDAP's LdapQueryBuilder, which allows attackers to read directory entries outside the scope an application intended. When a builder is created from an existing query, a later filter silently replaces the filter carried over from that query, so an LDAP search can run with broader criteria than intended and without any error.
Per OWASP: Access control enforces policy such that users cannot act outside of their intended permissions. Failures typically lead to unauthorized information disclosure, modification, or destruction of all data or performing a business function outside the user's limits.
This issue affects multiple versions of Spring LDAP.
Details
Module Info
- Product: Spring LDAP
- Affected packages:
org.springframework.ldap:spring-ldap-core - Affected versions: <=3.2.19, >=3.3.0 <=3.3.9, >=4.0.0 <=4.0.6, >=4.1.0 <=4.1.2
- GitHub repository: https://github.com/spring-projects/spring-ldap
- Published packages: https://central.sonatype.com/artifact/org.springframework.ldap/spring-ldap-core
- Package manager: Maven
- Fixed in:
- OSS Spring LDAP 4.0.7, 4.1.3
- NES for Spring LDAP
Vulnerability Info
This Medium-severity vulnerability is found in the org.springframework.ldap:spring-ldap-core package in multiple versions of Spring LDAP.
LdapQueryBuilder.fromQuery(LdapQuery) creates a new builder that is seeded with the base, scope, limits, attributes and filter of an existing query. It copies the source filter straight into the builder's rootContainer, but it never sets the isFilterStarted flag that the builder uses to enforce that a filter is specified only once:
public static LdapQueryBuilder fromQuery(LdapQuery query) {
LdapQueryBuilder builder = new LdapQueryBuilder();
builder.rootContainer = new DefaultContainerCriteria(builder).append(query.filter());
builder.attributes(query.attributes()).base(query.base());
// count limit, search scope and time limit copied as well
return builder;
}
private void initRootContainer() {
assertFilterNotStarted();
this.rootContainer = new DefaultContainerCriteria(this);
this.isFilterStarted = true;
}
private void assertFilterNotStarted() {
Assert.state(!this.isFilterStarted, "Invalid operation - filter condition specification already started");
}
Every filter entry point on the builder (where(String), filter(String), filter(Filter) and filter(String, Object...)) calls initRootContainer(). Because the flag is still false on a builder returned by fromQuery, the check passes and initRootContainer() replaces rootContainer with a fresh, empty container. The filter inherited from the source query is discarded instead of the call being rejected with an IllegalStateException.
An application that derives a builder from a query carrying a restricting filter (for example one that limits a search to a single tenant or organizational unit) and then adds a further filter will run a search that only applies the second filter. When the dropped filter was acting as an authorization boundary, an authenticated user can retrieve directory entries outside the scope the application intended. The same fromQuery pattern is used internally by LdapClient's search().query(Consumer<LdapQueryBuilder>) and by LdapTemplate.findForStream.
Steps to Reproduce
- Add
org.springframework.ldap:spring-ldap-coreat an affected version (for example 3.3.8) to a Java project. No LDAP server is needed. - Run the following program, which derives a builder from a tenant-scoped query and then adds a second filter:
import org.springframework.ldap.query.LdapQuery; import org.springframework.ldap.query.LdapQueryBuilder; public class Repro { public static void main(String[] args) { LdapQuery tenantScoped = LdapQueryBuilder.query() .base("ou=people") .where("ou").is("tenant-a"); LdapQueryBuilder derived = LdapQueryBuilder.fromQuery(tenantScoped); LdapQuery search = derived.filter("(objectClass=person)"); System.out.println(search.filter().encode()); } } - On an affected version the program prints
(objectClass=person): the(ou=tenant-a)restriction has been silently dropped. On a fixed version thefiltercall throws anIllegalStateExceptioninstead.
Mitigation
Only recent versions of Spring LDAP receive community support. Older lines are End-of-Life and will not receive public updates to address this issue.
Users of the affected components should apply one of the following mitigations:
- Upgrade to a currently supported version of Spring LDAP.
- Leverage a commercial support partner like HeroDevs for post-EOL security support.