Skip to content

Conversation

@Mmuzaf
Copy link
Contributor

@Mmuzaf Mmuzaf commented Nov 18, 2025

Description

This PR fixes an IllegalArgumentException that occured when resolved indices are empty in the PrivilegesEvaluator. This issue occurs when all indices are closed (e.g., during cluster maintenance) and operations like _cat/recovery are executed.

Category

Bug fix

Why these changes are required?

When all indices in a cluster are closed, certain operations like _cat/recovery can still be valid and should be authorized. However, when getAllIndicesResolved() returns an empty set, the code was attempting to create a CheckTable with an empty collection, which throws an IllegalArgumentException.

This prevents valid operations from being authorized when indices are closed.

What is the old behavior before changes and new behavior after changes?

Old behavior:

  • When all indices were closed and getAllIndicesResolved() returned an empty set, the code would attempt to create a CheckTable with an empty collection and throw an exception.

New behavior:

  • When getAllIndicesResolved() returns an empty set allow operations to proceed
  • Operations like _cat/recovery now succeed when users have the appropriate permissions, even when all indices are closed

Issues Resolved

Resolves #5794

Is this a backport?

No

Do these changes introduce new permission(s) to be displayed in the static dropdown on the front-end?

No

Testing

  • Added unit test hasIndexPrivilegeEmptyResolvedIndices()
  • Added integration test IndexAuthorizationWithClosedIndicesIntTests

Manual Testing

  • Verified that _cat/recovery and similar operations work correctly when all indices are closed

Check List

  • New functionality includes testing
  • New functionality has been documented (CHANGELOG.md updated)
  • New Roles/Permissions have a corresponding security dashboards plugin PR (N/A - no new permissions)
  • API changes companion pull request created (N/A - no API changes)
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@nibix
Copy link
Collaborator

nibix commented Nov 18, 2025

That looks quite good to me, thank you!

Just a few things:

@Mmuzaf Mmuzaf force-pushed the fix-resolved-indices-empty-ex branch from 4692a36 to b9d0dec Compare November 18, 2025 15:20
@Mmuzaf Mmuzaf changed the base branch from 2.19 to main November 18, 2025 15:25
@Mmuzaf Mmuzaf force-pushed the fix-resolved-indices-empty-ex branch 5 times, most recently from 96c8e4e to 91a7097 Compare November 20, 2025 15:45
@Mmuzaf
Copy link
Contributor Author

Mmuzaf commented Nov 20, 2025

@nibix during the implementation of the integration test, I encountered another edge case: if there are no indices, and users do not have any indices priveleges for the action at all, such requests should be also forbidden. To check this edge case I've added - a new method hasAnyIndexPrivilegeForAction. Could you please take a look if this is correct?

You've also mentioned IndexAuthorizationReadOnlyIntTests.java to add a new ingegration test there. I've added new IndexAuthorizationWithClosedIndicesIntTests instead for the following reasons:

  • we close all indices (including hidden ones) in order to perform a test on our specific case. In my opinion, this operation does not align with the read-only test as closing indices affects the whole IndexAuthorizationReadOnlyIntTests suite state;
  • adding new users to the USERS for our specific case in IndexAuthorizationReadOnlyIntTests suite affects all the tests in this suite due to the whole suite is parametrized, I thinks it's better to avoid it in our case;
  • we may want to expand test coverage for another issues when all indexes are closed;

wdyt?

@nibix
Copy link
Collaborator

nibix commented Nov 21, 2025

@Mmuzaf

Thanks for the update! On Friday, I will be quite busy with other stuff, so I will only have time to take a closer look on Monday.

if there are no indices, and users do not have any indices priveleges for the action at all, such requests should be also forbidden.

We need to take a closer look at this:

  • I believe that this behavior is the case also for all other index actions. If this is a fundamentally exposed behavior, we will likely have to mantain backwards compatiblity
  • For remote index operations, such a behavior is actually required. It is even possible that there are coordinator clusters with no local indices at all. In such cases it is expected that no local privileges are required.

Of course, this is a discussable topic - at the moment, we are working on some fundamental behavior changes (see #3905, #5367 and #5399 ; I also need to write an updated RFC soon). Feel invited to discuss there.

@cwperks cwperks added the v3.4.0 label Nov 24, 2025
@nibix
Copy link
Collaborator

nibix commented Nov 28, 2025

@Mmuzaf

Sorry for the late reply, was just too busy :-(

That looks generally very good to me! Yet, I think we need to briefly reflect on this:

if there are no indices, and users do not have any indices priveleges for the action at all, such requests should be also forbidden

If I see this correctly, this would have the following effect:

This is a kind of inconsistent behavior which we should avoid IMHO (even though it might be a case that seldomly happens in the real word).

For now, I would propose not to do the hasAnyIndexPrivilegeForAction() check to stay in sync with the existing behavior.

At the moment, we are busy on revising the index authorization behavior, see #5814. We could use that chance and implement the behavior change in that go. Feel invited to have a look there and comment :)

@cwperks wdyt?

@Mmuzaf Mmuzaf force-pushed the fix-resolved-indices-empty-ex branch from 91a7097 to 1c46d7d Compare December 2, 2025 17:31
@Mmuzaf
Copy link
Contributor Author

Mmuzaf commented Dec 2, 2025

@nibix thanks for the comment!

I agree with your suggestion. Let's keep the fix short and simple to avoid any problems with backwards compatibility, bearing in mind that the refactoring is still ongoing in other PRs. I've updated the PR to reflect our discussion and amended the description.

Is there anything else I need to do to get this into the next security plugin release (2.19.4.0)?

@Mmuzaf Mmuzaf marked this pull request as ready for review December 2, 2025 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] java.lang.IllegalArgumentException: Must contain at least one column and at least one row (got []/[indices:monitor/recovery])

3 participants