SOLR-18233 Strengthen Basic Authentication password policy and harden template users created by bin/solr auth enable (take2)#4534
Conversation
… template users created by bin/solr auth enable (apache#4477)
…cape hatch Document this in upgrade notes
…sysprop When the operator sets SOLR_SECURITY_AUTH_BASICAUTH_ALLOWUSERASPASSWORD=true in the shell running bin/solr, the CLI guard in AuthTool now passes through username==password credentials, matching the behaviour of the server-side Sha256AuthenticationProvider. Adds two new tests to AuthToolTest covering the rejection and escape-hatch paths; also resets ZK security.json before each test to prevent inter-test interference.
… auth After "Successfully enabled basic auth with username [X]", now also prints that user X was assigned the highest access level (superadmin, admin, index, search), so operators see a complete picture of their security setup alongside the template user list.
SecurityConfHandler was adding errorMessages to the response body but returning HTTP 200 / status:0, matching neither the client's expectation nor the pattern established by SchemaHandler and SolrConfigHandler which both throw SolrErrorWrappingException(BAD_REQUEST) on command errors. Align SecurityConfHandler with those handlers so that a failed set-user (e.g. password == username) returns HTTP 400. Update SecurityConfHandlerTest to assert the exception rather than inspecting the response NamedList.
There was a problem hiding this comment.
Pull request overview
This PR hardens Solr’s Basic Authentication by enforcing password != username (with an upgrade escape hatch), removing default usable credentials from the bin/solr auth enable template users, and fixing Security API error signaling to return proper HTTP 400 on command failures.
Changes:
- Enforce
username != passwordinSha256AuthenticationProviderfor both authentication andset-user, with an escape-hatch sysprop/env var to temporarily allow legacy behavior. - Harden
bin/solr auth enableby shipping template users with empty credentials and improving CLI messaging; update docs accordingly. - Fix Security API command failure handling to return HTTP 400 (throwing
SolrErrorWrappingException), and adjust tests to match.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| solr/webapp/web/js/angular/controllers/security.js | Adds client-side validation to reject password == username in the Admin UI. |
| solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java | Updates streaming tests to use passwords that differ from usernames. |
| solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc | Documents the new password policy and the temporary escape-hatch property/env var. |
| solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc | Expands bin/solr auth enable docs and clarifies blockUnknown defaults and template users. |
| solr/solr-ref-guide/modules/deployment-guide/pages/basic-authentication-plugin.adoc | Updates Basic Auth enablement guidance and notes the new set-user restriction. |
| solr/core/src/test/org/apache/solr/security/TestSha256AuthenticationProvider.java | Adds unit tests covering the new policy and escape-hatch behavior. |
| solr/core/src/test/org/apache/solr/security/BasicAuthOnSingleNodeTest.java | Updates test credentials to comply with username != password. |
| solr/core/src/test/org/apache/solr/security/AuthWithShardHandlerFactoryOverrideTest.java | Updates test credentials to comply with username != password. |
| solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java | Adjusts test expectations for Security API failures now throwing HTTP 400 exceptions. |
| solr/core/src/test/org/apache/solr/cloud/TestQueryingOnDownCollection.java | Updates test credentials to comply with username != password. |
| solr/core/src/test/org/apache/solr/cli/AuthToolTest.java | Adds CLI tests for rejecting/allowing username == password depending on escape hatch. |
| solr/core/src/resources/security.json | Removes pre-hashed template passwords and drops the superadmin template user mapping. |
| solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java | Implements the username != password enforcement and escape-hatch property lookup. |
| solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java | Throws SolrErrorWrappingException(BAD_REQUEST) on security command errors instead of returning 200 with embedded errors. |
| solr/core/src/java/org/apache/solr/cli/AuthTool.java | Prevents enabling Basic Auth with username == password unless escape hatch is enabled; adjusts blockUnknown handling and CLI output. |
| changelog/unreleased/SOLR-18233-Strengthen-Basic-Authentication-password-policy.yml | Adds an unreleased changelog entry describing the behavior change and escape hatch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var username = $scope.upsertUser.username ? $scope.upsertUser.username.trim() : ""; | ||
| if (password === username) { | ||
| $scope.validationError = "Password must not be the same as the username"; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
This is a fair comment. For operators who wish to disable the rule long-term, it makes sense for the UI to also respect this. Now that the HTTP call made by the UI will fail with HTTP 400, the user will be alerted through the normal error-message mechanism of the UI.
There was a problem hiding this comment.

This is take2, the first PR (#4477) was merged and then reverted. This time around we also modify some tests and add an escape hatch.
What changed
Four related hardening changes to Solr's Basic Authentication:
Password ≠ username enforcement (
Sha256AuthenticationProvider): both at login time and when setting a user viaset-user(API, Admin UI, CLI), Solr now rejects any credential where the password equals the username. This closes the most common weak-credential pattern where operators set up accounts likeadmin/admin.bin/solr auth enabletemplate hardening (security.json,AuthTool): the template shipped withbin/solr auth enableno longer contains pre-hashed passwords for the template users (admin,index,search). Those accounts are created with empty credentials (cannot log in until explicitly assigned a password). Thesuperadminuser and its pre-hashed password are removed entirely. The CLI now prints an explicit reminder after enabling auth that passwords must be set.Escape hatch for upgrades: a new system property
solr.security.auth.basicauth.allowuseraspassword(envSOLR_SECURITY_AUTH_BASICAUTH_ALLOWUSERASPASSWORD) temporarily allows username==password — both at login and user-management time — for operators who need to keep existing user account provisioning working while migrating, such as in test environments.Security API now returns HTTP 400 on command errors (
SecurityConfHandler): a pre-existing bug caused failedset-user(and other security command) operations to returnHTTP 200 / status:0with errors buried in anerrorMessagesbody field, rather than a properHTTP 400.SecurityConfHandlernow throwsSolrErrorWrappingException(BAD_REQUEST)on command errors, matching the pattern already used bySchemaHandlerandSolrConfigHandler.Why
Followup to plug the root cause of CVE-2026-44825 and further harden and document the CLI bootstrapping of basic auth.
In particular, the new username==password policy will effectively block attackers attempting to log in as
superadmin:superadminon systems that still have the vulnearble defaultsecurity.jsontemplate even after upgrading solr. This would mitigate the CVE also for users who never read our advisories.Docs
solr-control-script-reference.adoc: expandedbin/solr auth enablesection explaining the template users, their roles, and the--block-unknowndefault.basic-authentication-plugin.adoc: updated intro and added note thatset-userrejects username==password.major-changes-in-solr-10.adoc: upgrade note describing the new password policy and the escape hatch.How to review
Sha256AuthenticationProvider.java— two small guard blocks (one inauthenticate(), one in theset-usercommand handler). Both gate onSOLR_SECURITY_AUTH_BASICAUTH_ALLOWUSERASPASSWORD.AuthTool.java— one new guard before writingsecurity.json, and changedblockUnknownhandling to only override the template value when explicitly passed.security.json— credentials foradmin,index,searchare now empty strings;superadminremoved. Make sure it is impossible to log in to these accounts withuot first setting a password.TestSha256AuthenticationProviderhas new tests. Various integration tests updated to use passwords ≠ username.How to test manually
https://issues.apache.org/jira/browse/SOLR-18233