SOLR-18233 Strengthen Basic Authentication password policy and harden template users created by bin/solr auth enable#4477
Conversation
Clean up bin/solr auth enable template accounts
…er.authenticate() username.equals(password) threw NPE when username was null. The previous code handled null usernames safely via credentials.get(null), so this was a regression introduced by the new equality check.
… and set-user Adds two test methods to TestSha256AuthenticationProvider: - testAuthenticateRejectsUsernameEqualPassword: verifies that authenticate() returns false when username==password even if the hash is stored - testSetUserRejectsUsernameEqualPassword: verifies that the set-user edit command rejects entries where username==password
If an operator runs 'bin/solr auth enable --credentials admin:admin' with --block-unknown (the default), the created account will never authenticate, immediately locking them out. Fail early with a clear error message instead.
…son top level The --block-unknown flag was writing blockUnknown to the top level of security.json, but Solr reads it from security.json.authentication.blockUnknown. This meant the option had no effect and the template's value (false) was always used, a security-relevant bug since operators believed auth was mandatory when it was not.
The bullet describing what 'bin/solr auth enable' does pointed to solr/core/resources/security.json (missing src/). The correct path is solr/core/src/resources/security.json, matching the link added earlier in the same section.
epugh
left a comment
There was a problem hiding this comment.
LGTM! Thank you for tackling this.
epugh
left a comment
There was a problem hiding this comment.
err wait, i see a script test failing...
Yea, this was a tricky one. But I committed a fix, explained below: The CI "Run Solr Script Tests" job was failing on test 89 ( Root causeThe earlier commit in this PR correctly fixed On Fix
Risk of newly identified bugThe previously unknown bug of AuthTool setting the wrong |
|
I found a doc bug regarding default for basic-authentication-plugin.adoc
solr-control-script-reference.adoc
|
| [%autowidth,frame=none] | ||
| |=== | ||
| |Optional |Default: `true` | ||
| |Optional |Default: `false` (via template) |
There was a problem hiding this comment.
Should the "Default" for this CLI option instead of true or false be something like
"Use value from security.json template (false)"
That would perhaps allow us to simplify the explanation in line 971-972 below?
There was a problem hiding this comment.
i like... "via template" isn't obvious.
https://issues.apache.org/jira/browse/SOLR-18233
Password policy (affects all Basic Auth installations): Solr's Basic Authentication has had minimal password requirements. While the Admin UI enforced a few rules, it still permitted passwords identical to the username (e.g. admin/admin). This change disallows username/password equality both at login and at account creation, via the API and Admin UI alike. As a side effect, any existing installation retaining the well-known template credentials will have those accounts silently disabled until the passwords are changed.
bin/solr auth enablecleanup: The command previously uploaded a bundled security.json template containing four undocumented accounts with weak default credentials. With this change:These changes collectively strengthen the security posture of both new and existing Solr installations using Basic Authentication.