Contents
Apache Shiro’s CVE-2026-137686, posted to oss-security on November 26, carries a medium CVSS 4.0 score of 6.3. The concrete effect is bigger than that number suggests: a Shiro app that authenticates against a directory with ActiveDirectoryRealm could log in a user who submitted an empty username and an empty password. Two conditions apply: the realm has no principalSuffix configured, and the directory server accepts anonymous binds. The advisory lists shiro-core through 3.0.1 as affected and 3.0.2 as fixed.
The advisory calls this an incomplete fix for CVE-2014-0074, the same class of bug twelve years ago. The pattern underneath it, “the bind succeeded, so the user is who they said they are”, is a common way to write LDAP login code in any language, and the same gap can exist wherever that pattern skips an explicit empty-credential check.
Bind-to-authenticate, and a password check that compares the password to itself
Here is ActiveDirectoryRealm.queryForAuthenticationInfo as of 3.0.2. It is unchanged in substance from 3.0.1:
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
// Binds using the username and password provided by the user.
LdapContext ctx = null;
try {
ctx = ldapContextFactory.getLdapContext(getUsernameWithSuffixOrFullDN(upToken.getUsername()),
String.valueOf(upToken.getPassword()));
} finally {
LdapUtils.closeContext(ctx);
}
return buildAuthenticationInfo(upToken.getUsername(), upToken.getPassword());
If getLdapContext doesn’t throw, the realm returns a SimpleAuthenticationInfo whose stored credential is the password the user just typed. Shiro’s AuthenticatingRealm then runs its configured CredentialsMatcher, by default a SimpleCredentialsMatcher, which compares the submitted password with the stored credential. For this realm both sides are the same value, so the comparison always matches. The bind is the only real check.
That makes “what does a successful bind prove?” the whole security question. RFC 4513 defines three kinds of simple bind:
| Name | Password | RFC 4513 mechanism | What it proves |
|---|---|---|---|
| non-empty | non-empty | name/password (5.1.3) | the password is valid for that DN |
| non-empty | empty | unauthenticated (5.1.2) | nothing; the DN “is not to be authenticated or otherwise validated” |
| empty | empty | anonymous (5.1.1) | nothing; the client asked for an anonymous session |
A successful bind proves identity only in the first row. In the other two the server’s answer is “fine, you’re anonymous”, and code that checks only whether the bind threw will read that as a successful login.
What the 2014 fix covered
CVE-2014-0074 was the second row. Shiro 1.2.3 added validateAuthenticationInfo to its LDAP context factories (commit f9888462, February 2014, titled “Updating JndiLdapContextFactory to conform to spec rfc4513 section-5.1.2”). Here’s the current version from JndiLdapContextFactory:
if (SIMPLE_AUTHENTICATION_MECHANISM_NAME.equals(environment.get(Context.SECURITY_AUTHENTICATION))) {
// only validate credentials if we have a non-empty principal
if (environment.get(Context.SECURITY_PRINCIPAL) != null
&& StringUtils.hasText(String.valueOf(environment.get(Context.SECURITY_PRINCIPAL)))) {
Object credentials = environment.get(Context.SECURITY_CREDENTIALS);
// ... throw if credentials are null or empty
}
}
The guard deliberately skips the empty-principal case. That’s reasonable for a context factory, because the same getLdapContext method also serves system connections, and an anonymous system bind is a legitimate configuration. The factory can’t tell whether a call came from “connect to search the directory” or “check this user’s password”. Only the realm knows that, and the realm never checked.
How an empty username reaches the anonymous row
getUsernameWithSuffixOrFullDN decides what name to bind with. With no principalSuffix, it first tries to parse the username as a distinguished name and returns it unchanged if it has more than one RDN. An empty string parses as an LdapName with zero RDNs, so it falls through to getUsernameWithSuffix, which sanitizes it and appends nothing. The bind name is "", the password is "", the factory’s guard is skipped because the principal is empty, and the directory receives a textbook anonymous bind.
With a principalSuffix like @example.com, the same empty username becomes @example.com. That is non-empty, so the 2014 guard runs and rejects the empty password before any network call. This is why the advisory lists setting principalSuffix as a workaround.
Compare DefaultLdapRealm, the other LDAP realm. Its getUserDn starts with:
if (!StringUtils.hasText(principal)) {
throw new IllegalArgumentException("User principal cannot be null or empty for User DN construction.");
}
It checks for an empty principal at the realm, where the code knows a user is logging in. ActiveDirectoryRealm relied on the factory, and the factory had a hole there on purpose.
Whether the directory accepts the bind is the second condition, and the defaults differ between the two cases. In OpenLDAP’s slapd.conf, unauthenticated binds with a non-empty DN are off unless you set allow bind_anon_dn. Anonymous binds are accepted unless you set disallow bind_anon. A directory set up to refuse the 2014 case can still accept the 2026 case without any change.
Where 3.0.2 puts the fix
I diffed shiro-root-3.0.1 against shiro-root-3.0.2. The only changes to ActiveDirectoryRealm, JndiLdapContextFactory and AbstractLdapRealm are added @Override annotations. The bind path is the same. The fix is commit ecd3abad, “ensure passwordsMatch method returns false for null or empty saved credentials”, by Lenny Primak, who is also named as the remediation developer in the advisory. It adds this to the top of SimpleCredentialsMatcher.equals:
if (accountCredentials == null
|| (isByteSource(accountCredentials) && toBytes(accountCredentials).length == 0)) {
// an empty or missing stored credential never matches anything
return false;
}
isByteSource returns true for char[], so the empty password the AD realm stores as the account credential now fails the match. The anonymous bind still goes to the directory and still succeeds. Shiro just refuses the result afterwards.
The same commit changes both passwordsMatch overloads in DefaultPasswordService. Before, an empty saved password matched an empty submitted password:
if (saved == null || saved.isEmpty()) {
return false; // was: return plaintextBytes == null || plaintextBytes.isEmpty();
}
This is a global behavior change, not a fix scoped to LDAP. HashedCredentialsMatcher extends SimpleCredentialsMatcher and ends in the same equals call, so any realm that uses either matcher and returns an empty stored credential now fails authentication for every input. That covers an account defined with a blank password, a JdbcRealm row with an empty password column, or a custom realm that returns "" to mean “no password needed”. Most of those accounts are mistakes, and refusing them is the right default. But if something in your system relied on one, such as a kiosk user or a service account in a test fixture, it stops working on 3.0.2.
The 2.x line
The 2.x line’s latest release is 2.2.1, from June 2026. As of this writing, neither that tag’s SimpleCredentialsMatcher nor the 2.x branch’s version has the empty-credential check, and there is no 2.x release after the advisory. The advisory’s affected range, “through 3.0.1”, includes all of 2.x. If you’re on 2.x, your options today are the configuration workarounds, or moving to 3.0.2.
What to check
- Find every
ActiveDirectoryRealmin your Shiro config (shiro.ini, Spring beans, or code). IfprincipalSuffixisn’t set, you match the first condition. - Check whether your directory accepts anonymous binds. With OpenLDAP’s client tools,
ldapwhoami -x -H ldaps://your-dcwith no-Dand no-wsends a simple bind with an empty name and password. If that succeeds, you match the second condition. - Upgrade to
shiro-core3.0.2. Before you deploy it, search your realms and fixtures for accounts with empty stored passwords, since those stop authenticating. - If you can’t upgrade, set
principalSuffixon the realm, or disable anonymous binds on the directory. The suffix closes the gap inside the app no matter how the directory is configured, so I’d do that even after upgrading. - If you wrote your own bind-to-authenticate code with Shiro, Spring LDAP, python-ldap or anything else, reject an empty username and an empty password before you call bind. Don’t rely on the LDAP library or the server to refuse them. RFC 4513 tells clients to do exactly this: “Clients SHOULD disallow an empty password input to a Name/Password Authentication user interface.”
The realm is the only layer that knows a bind is meant to prove someone’s identity. The context factory, the JNDI provider and the directory each see an ordinary request. The empty-credential check belongs in the realm, and in Shiro’s case it now lives one layer further up, in the matcher.
Sources
- oss-security: CVE-2026-137686, Apache Shiro authentication bypass in ActiveDirectoryRealm via empty username
- Apache Shiro commit ecd3abad: passwordsMatch returns false for null or empty saved credentials
- Apache Shiro commit f9888462: the 2014 RFC 4513 section 5.1.2 check
ActiveDirectoryRealm.javaat shiro-root-3.0.2JndiLdapContextFactory.javaat shiro-root-3.0.2- RFC 4513, section 5.1: simple bind mechanisms
- OpenLDAP
slapd.conf(5):allowanddisallow