Skip to content

Commit 3a82e0f

Browse files
Do not rewrite aliases on remove-index from aliases requests (#46989) (#47018)
When we rewrite alias requests, after filtering down to only those that the user is authorized to see, it can be that there are no aliases remaining in the request. However, core Elasticsearch interprets this as _all so the user would see more than they are authorized for. To address this, we previously rewrote all such requests to have aliases `"*"`, `"-*"`, which would be interpreted when aliases are resolved as nome. Yet, this is only needed for get aliases requests and we were applying it to all alias requests, including remove index requests. If such a request was sent to a coordinating node that is not the master node, the request would be rewritten to include `"*"` and `"-*"`, and then the master would authorize the user for these. If the user had limited permissions, the request would fail, even if they were authorized on the index that the remove index action was over. This commit addresses this by rewriting for get aliases and remove aliases request types but not for the remove index. Co-authored-by: Albert Zaharovits <[email protected]> Co-authored-by: Tim Vernum <[email protected]>
1 parent 64bf1b5 commit 3a82e0f

File tree

3 files changed

+129
-54
lines changed

3 files changed

+129
-54
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolver.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,15 @@ ResolvedIndices resolveIndicesAndAliases(IndicesRequest indicesRequest, MetaData
210210
} else {
211211
resolvedIndicesBuilder.addLocal(aliasesRequest.aliases());
212212
}
213-
// if no aliases are authorized, then fill in an expression that
214-
// MetaData#findAliases evaluates to the empty alias list. You cannot put
215-
// "nothing" (the empty list) explicitly because this is resolved by es core to
216-
// _all
217-
if (aliasesRequest.aliases().length == 0) {
213+
/*
214+
* If no aliases are authorized, then fill in an expression that MetaData#findAliases evaluates to an
215+
* empty alias list. We can not put an empty list here because core resolves this as _all. For other
216+
* request types, this replacement is not needed and can trigger issues when we rewrite the request
217+
* on the coordinating node. For example, for a remove index request, if we did this replacement,
218+
* the request would be rewritten to include "*","-*" and for a user that does not have permissions
219+
* on "*", the master node would not authorize the request.
220+
*/
221+
if (aliasesRequest.expandAliasesWildcards() && aliasesRequest.aliases().length == 0) {
218222
aliasesRequest.replaceAliases(NO_INDICES_OR_ALIASES_ARRAY);
219223
}
220224
}

0 commit comments

Comments
 (0)