Skip to content

Conversation

@jfreden
Copy link
Contributor

@jfreden jfreden commented Oct 15, 2025

This PR optimizes how index permission automatons are created.

In #110633 a feature was added to allow for doing regular expression "has privilege" style checks against index permission groups. The reason this was added was to support regular expressions for the manage_roles privilege (so unrelated to the has privileges API). The implementation was known to have performance issues and the change was therefore made optional (and disabled in the has privileges API). Unfortunately, a change to simplify the logic by doing Automatons.unionAndMinimize on all index permissions in a group was left outside the conditional and therefore caused a performance regression.

See this comment for details on the original change.

slobodanadamovic added a commit to slobodanadamovic/elasticsearch that referenced this pull request Oct 15, 2025
@jfreden
Copy link
Contributor Author

jfreden commented Oct 16, 2025

The reported CI failure in serverless is valid I think:

REPRODUCE WITH: ./gradlew ":modules:serverless-security:javaRestTest" --tests "co.elastic.elasticsearch.serverless.security.crossproject.CrossProjectSearchRestIT.testCrossProjectResolveIndexWithUniversalApiKey" -Dtests.seed=286311FBFFFE4865 -Dtests.locale=ar-DZ -Dtests.timezone=America/Rainy_River -Druntime.java=25
  |  
  | CrossProjectSearchRestIT > testCrossProjectResolveIndexWithUniversalApiKey FAILED
  | org.elasticsearch.client.ResponseException: method [GET], host [http://[::1]:33125], URI [/_resolve/index/_all], status line [HTTP/1.1 500 Internal Server Error]
  | {"error":{"root_cause":[{"type":"null_pointer_exception","reason":"Cannot invoke \"org.elasticsearch.action.ResolvedIndexExpressions.expressions()\" because \"localResolvedExpressions\" is null"}],"type":"null_pointer_exception","reason":"Cannot invoke \"org.elasticsearch.action.ResolvedIndexExpressions.expressions()\" because \"localResolvedExpressions\" is null"},"status":500}
  | at __randomizedtesting.SeedInfo.seed([286311FBFFFE4865:AD3657883BFBAD09]:0)
  | at app//org.elasticsearch.client.RestClient.convertResponse(RestClient.java:351)
  | at app//org.elasticsearch.client.RestClient.performRequest(RestClient.java:317)
  | at app//org.elasticsearch.client.RestClient.performRequest(RestClient.java:292)
  | at app//co.elastic.elasticsearch.serverless.security.cloud.AbstractUniversalIamIT.performRequestWithCloudApiKey(AbstractUniversalIamIT.java:208)
  | at app//co.elastic.elasticsearch.serverless.security.cloud.AbstractUniversalIamIT.performRequestWithCloudApiKey(AbstractUniversalIamIT.java:198)
  | at app//co.elastic.elasticsearch.serverless.security.crossproject.CrossProjectSearchRestIT.resolveIndicesAndAssert(CrossProjectSearchRestIT.java:792)
  | at app//co.elastic.elasticsearch.serverless.security.crossproject.CrossProjectSearchRestIT.testCrossProjectResolveIndexWithUniversalApiKey(CrossProjectSearchRestIT.java:381)
  |  

Working on reproducing locally now.

@jfreden jfreden added >bug :Security/Security Security issues without another label labels Oct 16, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@jfreden jfreden added v8.19.6 v9.1.6 v9.2.1 auto-backport Automatically create backport pull requests when merged labels Oct 16, 2025
@jfreden jfreden marked this pull request as ready for review October 16, 2025 07:27
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Oct 16, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@jfreden jfreden changed the title Optimize index permissions Optimizes Index Permission Automatons for Has Privileges Oct 16, 2025
@jfreden jfreden changed the title Optimizes Index Permission Automatons for Has Privileges Optimize Index Permission Automatons for Has Privileges Oct 16, 2025
@@ -0,0 +1,5 @@
pr: 136625
summary: Optimize index permissions
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will update this as soon as CI finishes

Choose a reason for hiding this comment

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

136625

Copy link
Contributor

@slobodanadamovic slobodanadamovic left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Thanks for fixing it!

@jfreden jfreden added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Oct 16, 2025
@elasticsearchmachine elasticsearchmachine merged commit 3df0abb into elastic:main Oct 16, 2025
40 checks passed
@jfreden jfreden deleted the fix_combine_groups_issue branch October 16, 2025 09:36
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts
9.1
9.2

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 136625

jfreden added a commit to jfreden/elasticsearch that referenced this pull request Oct 16, 2025
This PR optimizes how index permission automatons are created. 

In elastic#110633 a feature was
added to allow for doing regular expression "has privilege" style checks
against index permission groups. The reason this was added was to
support regular expressions for the `manage_roles` privilege (so
unrelated to the has privileges API). The implementation was known to
have performance issues and the change was therefore made optional (and
disabled in the has privileges API). Unfortunately, a change to simplify
the logic by doing `Automatons.unionAndMinimize` on all index
permissions in a group was left outside the conditional and therefore
caused a performance regression. 

See
[this](https://github.com/elastic/elasticsearch/blob/2a9c07eb6fe4e8bbb7fc9fbab6fa59ccc006e10b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java#L840-L860)
comment for details on the original change.
jfreden added a commit to jfreden/elasticsearch that referenced this pull request Oct 16, 2025
This PR optimizes how index permission automatons are created. 

In elastic#110633 a feature was
added to allow for doing regular expression "has privilege" style checks
against index permission groups. The reason this was added was to
support regular expressions for the `manage_roles` privilege (so
unrelated to the has privileges API). The implementation was known to
have performance issues and the change was therefore made optional (and
disabled in the has privileges API). Unfortunately, a change to simplify
the logic by doing `Automatons.unionAndMinimize` on all index
permissions in a group was left outside the conditional and therefore
caused a performance regression. 

See
[this](https://github.com/elastic/elasticsearch/blob/2a9c07eb6fe4e8bbb7fc9fbab6fa59ccc006e10b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java#L840-L860)
comment for details on the original change.
@jfreden
Copy link
Contributor Author

jfreden commented Oct 16, 2025

💚 All backports created successfully

Status Branch Result
8.19

Questions ?

Please refer to the Backport tool documentation

jfreden added a commit to jfreden/elasticsearch that referenced this pull request Oct 16, 2025
This PR optimizes how index permission automatons are created.

In elastic#110633 a feature was
added to allow for doing regular expression "has privilege" style checks
against index permission groups. The reason this was added was to
support regular expressions for the `manage_roles` privilege (so
unrelated to the has privileges API). The implementation was known to
have performance issues and the change was therefore made optional (and
disabled in the has privileges API). Unfortunately, a change to simplify
the logic by doing `Automatons.unionAndMinimize` on all index
permissions in a group was left outside the conditional and therefore
caused a performance regression.

See
[this](https://github.com/elastic/elasticsearch/blob/2a9c07eb6fe4e8bbb7fc9fbab6fa59ccc006e10b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java#L840-L860)
comment for details on the original change.

(cherry picked from commit 3df0abb)

# Conflicts:
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java
elasticsearchmachine pushed a commit that referenced this pull request Oct 16, 2025
…36674)

This PR optimizes how index permission automatons are created. 

In #110633 a feature was
added to allow for doing regular expression "has privilege" style checks
against index permission groups. The reason this was added was to
support regular expressions for the `manage_roles` privilege (so
unrelated to the has privileges API). The implementation was known to
have performance issues and the change was therefore made optional (and
disabled in the has privileges API). Unfortunately, a change to simplify
the logic by doing `Automatons.unionAndMinimize` on all index
permissions in a group was left outside the conditional and therefore
caused a performance regression. 

See
[this](https://github.com/elastic/elasticsearch/blob/2a9c07eb6fe4e8bbb7fc9fbab6fa59ccc006e10b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java#L840-L860)
comment for details on the original change.
jfreden added a commit that referenced this pull request Oct 16, 2025
…36678)

This PR optimizes how index permission automatons are created.

In #110633 a feature was
added to allow for doing regular expression "has privilege" style checks
against index permission groups. The reason this was added was to
support regular expressions for the `manage_roles` privilege (so
unrelated to the has privileges API). The implementation was known to
have performance issues and the change was therefore made optional (and
disabled in the has privileges API). Unfortunately, a change to simplify
the logic by doing `Automatons.unionAndMinimize` on all index
permissions in a group was left outside the conditional and therefore
caused a performance regression.

See
[this](https://github.com/elastic/elasticsearch/blob/2a9c07eb6fe4e8bbb7fc9fbab6fa59ccc006e10b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java#L840-L860)
comment for details on the original change.

(cherry picked from commit 3df0abb)

# Conflicts:
#	x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java
elasticsearchmachine pushed a commit that referenced this pull request Oct 16, 2025
…36673)

This PR optimizes how index permission automatons are created. 

In #110633 a feature was
added to allow for doing regular expression "has privilege" style checks
against index permission groups. The reason this was added was to
support regular expressions for the `manage_roles` privilege (so
unrelated to the has privileges API). The implementation was known to
have performance issues and the change was therefore made optional (and
disabled in the has privileges API). Unfortunately, a change to simplify
the logic by doing `Automatons.unionAndMinimize` on all index
permissions in a group was left outside the conditional and therefore
caused a performance regression. 

See
[this](https://github.com/elastic/elasticsearch/blob/2a9c07eb6fe4e8bbb7fc9fbab6fa59ccc006e10b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java#L840-L860)
comment for details on the original change.
Kubik42 pushed a commit to Kubik42/elasticsearch that referenced this pull request Oct 16, 2025
This PR optimizes how index permission automatons are created. 

In elastic#110633 a feature was
added to allow for doing regular expression "has privilege" style checks
against index permission groups. The reason this was added was to
support regular expressions for the `manage_roles` privilege (so
unrelated to the has privileges API). The implementation was known to
have performance issues and the change was therefore made optional (and
disabled in the has privileges API). Unfortunately, a change to simplify
the logic by doing `Automatons.unionAndMinimize` on all index
permissions in a group was left outside the conditional and therefore
caused a performance regression. 

See
[this](https://github.com/elastic/elasticsearch/blob/2a9c07eb6fe4e8bbb7fc9fbab6fa59ccc006e10b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java#L840-L860)
comment for details on the original change.
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 auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport pending >bug :Security/Security Security issues without another label Team:Security Meta label for security team v8.19.6 v9.1.6 v9.2.1 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants