Skip to content

Fix rollover authorization checks - #157955

Draft
slobodanadamovic wants to merge 3 commits into
mainfrom
sa-rollover-fix
Draft

Fix rollover authorization checks#157955
slobodanadamovic wants to merge 3 commits into
mainfrom
sa-rollover-fix

Conversation

@slobodanadamovic

@slobodanadamovic slobodanadamovic commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Authorization for a rollover now consists of 3 parts:

  1. checks indices:admin/rollover on the target alias (unchanged first pass)
  2. checks indices:admin/create on the resolved new index name - the new second pass
  3. checks indices:admin/aliases on the target plus body aliases plus the new index name - the new third pass

Authorization for a rollover now consists of 3 parts:

- `indices:admin/rollover` on the target alias (unchanged first pass).
- `indices:admin/create` on the resolved new index name - the new pass. The resolved name comes from the shared MetadataRolloverService.resolveRolloverIndexName, computed once and reused by both passes.
- `indices:admin/aliases` on the target plus body aliases plus the new index name
@slobodanadamovic slobodanadamovic self-assigned this Aug 28, 2026
@slobodanadamovic slobodanadamovic added >bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team auto-backport Automatically create backport pull requests when merged branch:8.19 branch:9.4 branch:9.5 labels Aug 28, 2026
@elasticsearchmachine

Copy link
Copy Markdown
Collaborator

Hi @slobodanadamovic, I've created a changelog YAML for you.

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🔍 Preview links for changed docs

⏳ Building and deploying preview... View progress

This comment will be updated with preview links when the build is complete.

@github-actions

Copy link
Copy Markdown
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

private final String[] checkedNames;

DataStreamAuthorizationRequest(ModifyDataStreamsAction.Request delegate, String[] dataStreamNames) {
SecondaryAuthorizationRequest(IndicesRequest delegate, String[] checkedNames) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to any naming suggestions here. The SecondaryAuthorizationRequest's intention is to be a wrapper for any sub-sequent authorization calls. It's usage is primarily for auditing the correct names (indices, aliases or data streams)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-stage rollover authorization to prevent unauthorized index creation and alias attachment.

Changes:

  • Adds create-index and alias authorization passes.
  • Adds unit and REST integration coverage.
  • Exposes rollover index-name resolution for authorization.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AuthorizationService.java Implements secondary authorization checks.
AuthorizationServiceTests.java Tests rollover authorization and auditing.
RolloverAliasSecurityRestIT.java Adds end-to-end security tests.
MetadataRolloverService.java Exposes date-math name resolution.
157955.yaml Adds the changelog entry.
Suppressed comments (1)

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java:840

  • This resolution is not guaranteed to produce the name that is eventually created. resolveRolloverIndexName reads the current clock, while TransportRolloverAction resolves the expression again during the pre-check and cluster-state task (TransportRolloverAction.java:216 and :555). A valid expression with second- or millisecond-level formatting can therefore be authorized as one exact index and later create another. Bind the authorized concrete name (or timestamp) to execution, or authorize the final name.
                // Authorize the same concrete name MetadataRolloverService will create.
                rolloverNewIndexName = MetadataRolloverService.resolveRolloverIndexName(rolloverRequest.getNewIndexName());

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +836 to +840
if (request instanceof RolloverRequest rolloverRequest) {
aliases = rolloverRequest.getCreateIndexRequest().aliases();
if (rolloverRequest.getNewIndexName() != null) {
// Authorize the same concrete name MetadataRolloverService will create.
rolloverNewIndexName = MetadataRolloverService.resolveRolloverIndexName(rolloverRequest.getNewIndexName());
Comment on lines +929 to +933
// Substitute a request whose indices() are the names this pass checks, so audit events and the denial
// message name the offending alias or index instead of the original request's rollover target.
final RequestInfo aliasesRequestInfo = new RequestInfo(
requestInfo.getAuthentication(),
request,
new SecondaryAuthorizationRequest((IndicesRequest) requestInfo.getRequest(), checkedNames.toArray(String[]::new)),
Comment on lines +842 to +849
} else if (request instanceof CreateDataStreamAction.Request
|| request instanceof MigrateToDataStreamAction.Request
|| request instanceof PastTimeSeriesIndexCreationAction.Request) {
aliases = Set.of();
} else {
// Casting to CreateIndexRequest is safe only because it's the last possible option; always keep it last!
aliases = ((CreateIndexRequest) request).aliases();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v8.19.22 v9.4.7 v9.5.3 v9.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants