Skip to main content
Menu
Advisories

Authentication bypass via LDAP unauthenticated bind with an empty password in micronaut-security-ldap

GHSA-V3R7-5GPG-H258Published Updated GitHub

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 UsernamePasswordCredentials parameter 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-validation to the classpath so the /login endpoint rejects blank passwords, and disable Basic authentication with micronaut.security.basic-auth.enabled=false if it is not needed.
  • Wrap or replace LdapAuthenticationProvider with 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

Fix commits

Affected versions

References

GitHub · micronaut-projects/micronaut-security