Authentication bypass via LDAP unauthenticated bind with an empty password in micronaut-security-ldap
Description
Packages and affected stable versions:
io.micronaut.configuration:micronaut-security-ldap(legacy coordinates):>= 1.0.0, <= 1.4.0. The first affected stable version is 1.0.0.io.micronaut.security:micronaut-security-ldap:>= 2.0.0, <= 3.11.1;>= 4.0.0, <= 4.18.0;>= 5.0.0, <= 5.4.0; and= 5.5.0.
Patched versions: Under io.micronaut.security, upgrade to 3.11.2, 4.18.1, 5.4.1, or 5.5.1 for the corresponding release line. No patched release was published under the legacy io.micronaut.configuration coordinates; migrate to io.micronaut.security:micronaut-security-ldap and use a patched version.
LdapAuthenticationProvider in micronaut-security-ldap performs an LDAP simple bind using the password supplied in the authentication request without first checking that the password is non-empty. RFC 4513 §5.1.2 defines a simple bind with a non-empty DN and an empty password as an unauthenticated bind. Active Directory accepts unauthenticated binds by default, and OpenLDAP accepts them when allow bind_anon_cred is set. Against such a directory, the bind succeeds and Micronaut Security treats the user as authenticated.
An unauthenticated remote attacker who knows or guesses a valid username can therefore log in as that user with an empty password.
Details
The provider resolves the user's DN with the manager account and then binds as that DN using the request secret verbatim:
// security-ldap/src/main/java/io/micronaut/security/ldap/LdapAuthenticationProvider.java
String password = authenticationRequest.getSecret().toString();
...
userContext = contextBuilder.build(configuration.getSettings(result.getDn(), password));DefaultContextBuilder sets java.naming.security.authentication=simple and passes the (possibly empty) credentials through to InitialDirContext. The JDK LDAP provider performs no client-side check, so the empty bind reaches the server.
Whether the request can carry an empty password depends on the entry point:
- HTTP Basic authentication (
BasicAuthAuthenticationFetcher, enabled by default):
Authorization: Basic base64("alice:") is decoded into UsernamePasswordCredentials("alice", "") with no validation. Vulnerable.
POST/login(LoginController): the @Valid @Body UsernamePasswordCredentialsparameter is annotated@NotBlank, so an empty password is rejected with 400 only when micronaut-validation is on the classpath. Without it, the request reaches the provider. Vulnerable unless validation is present.- Custom callers of
AuthenticationProvider.authenticate(...)(for example a custom login endpoint or a WebSocket handshake) pass credentials straight through. Vulnerable.
Impact
Complete authentication bypass for any account in the directory when the LDAP server accepts unauthenticated binds. The attacker obtains the victim's full identity, including the groups resolved by the provider, and can access any endpoint secured by role.
Deployments whose directory rejects unauthenticated binds (OpenLDAP defaults, or Active Directory with LDAPServerIntegrity/Deny unauthenticated binds enforced) are not exploitable, but the library still sends the empty-password bind to the server and reports the server's rejection as AuthenticationFailureReason.UNKNOWN rather than CREDENTIALS_DO_NOT_MATCH.
Proof of concept
Against an application configured with micronaut.security.ldap.default.* pointing at an Active Directory domain controller with default settings, and with Basic authentication enabled (the default):
curl -i -u 'alice:' https://app.example.com/secured
The response is 200 OK with the resource, and SecurityService.username() reports alice. The same request with a wrong non-empty password returns 401.
Patches
LdapAuthenticationProvider now returns AuthenticationResponse.failure(AuthenticationFailureReason.CREDENTIALS_DO_NOT_MATCH) before contacting the directory when the supplied secret is null or empty. Upgrade to 3.11.2, 4.18.1, 5.4.1, or 5.5.1 for the corresponding release line.
Workarounds
- Configure the directory to reject unauthenticated binds (on Active Directory, set
LDAPServerIntegrity and the "Deny unauthenticated binds" attribute on the NTDS Settings object; on OpenLDAP, do not set allow bind_anon_cred).
- Add
micronaut-validationto the classpath so the /login endpoint rejects blank passwords, and disable Basic authentication withmicronaut.security.basic-auth.enabled=falseif it is not needed. - Wrap or replace
LdapAuthenticationProviderwith an implementation that rejects empty secrets before delegating.
Score
This advisory is scored CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N (7.4, High).
Attack complexity is rated High rather than Low because exploitation depends on a condition outside the attacker's control: the LDAP directory must accept unauthenticated simple binds. Active Directory accepts them by default, so many deployments meet the condition without any operator action, but OpenLDAP and hardened Active Directory forests do not. Where the condition holds, no privileges, no user interaction and no further complexity are required, and the attacker obtains the full identity of any account whose username they know. Operators running Active Directory with default settings should treat this as Critical for their environment.
References
- RFC 4513 §5.1.2, Unauthenticated Authentication Mechanism of Simple Bind: rfc-editor.org/
rfc/ rfc4513#section-5.1.2 - CWE-287, Improper Authentication: cwe.mitre.org/
data/ definitions/ 287.html - Microsoft, "Unauthenticated binds" (LDAP channel binding and signing guidance): learn.microsoft.com/
en-us/ troubleshoot/ windows-server/ active-directory/ enable-ldap-signing-in-windows-server
Fix commits
- Micronaut Security 5.5.x (5.5.1): github.com/
micronaut-projects/ micronaut-security/ commit/ 90a299139f189f6cb28fbe67526f5121ff6f89a4 - Micronaut Security 5.4.x (5.4.1): github.com/
micronaut-projects/ micronaut-security/ commit/ ff489d30cfaeccf7faa6339d2920e7aae7778781 - Micronaut Security 4.x (4.18.1): github.com/
micronaut-projects/ micronaut-security/ commit/ 51ccc65bcef941c5b88babc8801f346fd9154aa8 - Micronaut Security 3.x (3.11.2): github.com/
micronaut-projects/ micronaut-security/ commit/ a87af4f643d7eb20bb7807134603ea8d2363cf4c