Skip to content

Commit 738d1a3

Browse files
authored
Update assertion in setResolvedIndexExpressionsIfUnset (elastic#138866)
Instead of fully suppressing the assertion due to the known issue, this PR adds two more relaxed assertions so that we can be sure the issue does not expand in future. Relates: elastic#135799
1 parent d7b3784 commit 738d1a3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,15 @@ private static void setResolvedIndexExpressionsIfUnset(IndicesRequest.Replaceabl
569569
+ replaceable.getClass().getName()
570570
+ "]";
571571
logger.debug(message);
572-
// we are excepting `*,-*` below since we've observed this already -- keeping this assertion to catch other cases
573-
// If more exceptions are found, we can add a comment to above linked issue and relax this check further
574-
// assert replaceable.indices() == null || isNoneExpression(replaceable.indices()) : message;
572+
// Double authorization and hence index resolution can happen first in ServerTransportFilter and then in SecurityActionFilter.
573+
// This cannot happen on the coordinating node since it does not involve ServerTransportFilter. Therefore, there should be no
574+
// remote indices.
575+
assert replaceable.getResolvedIndexExpressions().getRemoteIndicesList().isEmpty() && resolved.getRemoteIndicesList().isEmpty()
576+
: message;
577+
// Since the first resolution expands all wildcards, the second resolution is performed against concrete names.
578+
// As a result, the resolved indices from the second resolution must be identical (most likely) or a subset of the
579+
// resolved indices from the first resolution if the user's role changes in between the two authorizations.
580+
assert replaceable.getResolvedIndexExpressions().getLocalIndicesList().containsAll(resolved.getLocalIndicesList()) : message;
575581
}
576582
}
577583

0 commit comments

Comments
 (0)