-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
do_not_fail_on_forbidden mode introduces inconsistencies for mget, msearch and similar actions #4485
Comments
This special handling does not provide any benefits - rather it just causes some inconsistent behavior. Fixes opensearch-project#4485 Signed-off-by: Nils Bandener <[email protected]>
This special handling does not provide any benefits - rather it just causes some inconsistent behavior. Fixes opensearch-project#4485 Signed-off-by: Nils Bandener <[email protected]>
[Triage] Hi Nils, thanks for filing this issue. Looks good, will mark as triaged. |
This special handling does not provide any benefits - rather it just causes some inconsistent behavior. Fixes opensearch-project#4485 Signed-off-by: Nils Bandener <[email protected]>
This special handling does not provide any benefits - rather it just causes some inconsistent behavior. Fixes opensearch-project#4485 Signed-off-by: Nils Bandener <[email protected]>
This special handling does not provide any benefits - rather it just causes some inconsistent behavior. Fixes opensearch-project#4485 Signed-off-by: Nils Bandener <[email protected]>
@nibix Thank you very much for the detailed issue. It would definitely be good to implement a fix for this to avoid having to duplicate action names across |
+1 @nibix This is very detailed, and would definitely help alleviate pains with DNFOF.
Will the implementation of this issue address this by adding support for multiple indices? |
No, it is a fundamental propery of |
Thank you @nibix. I should have been more clearer by mentioning mget. Regardless, it seems like you have already raised a PR to fix this. |
This is a facet of the work done for #3870. A corresponding PR will immediately follow up, which is a part of the changes done in #4380
The implementation of the
do_not_fail_on_forbidden
mode in conjunction with multi-part requests likemget
,msearch
,mtv
and other index-independent read operations likescroll
seems to be inconsistent on several levels.The
PrivilegesEvaluator
class gives certain cluster actions a special treatment fordo_not_fail_on_forbidden
mode atsecurity/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java
Line 414 in 37afcaa
The affected actions are determined by
action0.startsWith("indices:data/read/")
and the conditions that determine whether an action is a cluster action:security/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java
Line 696 in 37afcaa
This results in the following actions being handled here:
indices:data/read/scroll
indices:data/read/mget
indices:data/read/msearch
indices:data/read/mtv
indices:data/read/search/template/render
In any case, these permissions are checked as cluster permission with the method
securityRoles.impliesClusterPermissionPermission(action0)
.The special treatment for
do_not_fail_on_forbidden
which is executed afterwards looks like this:This results in some inconsistencies described in the following.
Privileges need to be specified both in cluster_privileges and index_privileges
As described before, the affected actions such as
indices:data/read/mget
are considered as cluster actions, so these need to be specified in thecluster_privileges
section of a role.securityRoles.reduce()
now however is an index-specific operation, so it checks theindex_privileges
of a role. Thus, indo_not_fail_on_forbidden
mode, the privileges forindices:data/read/mget
need to be present inindex_privileges
as well. This is inconsistent to the mode wheredo_not_fail_on_forbidden
is turned off, the index privileges forindices:data/read/mget
are not needed in that case.It is also confusing and surprising to the user. The docs at https://opensearch.org/docs/latest/security/access-control/permissions/#cluster-permissions say on one hand:
But in the table below it mentions for
mget
and related actions:This is a contradiction to the first sentence. Additionally, it is not true when
do_not_fail_on_forbidden
is turned off._mget
gains an invalid index pattern support indo_not_fail_on_forbidden
modeIn OpenSearch, the
_get
API and indivual items in_mget
API requests always refer to exactly one index, so index patterns are not supported here. If you try to use an index pattern, you will usually get an error:When having
do_not_fail_on_forbidden
enabled, however, index patterns are supported at least in some cases like the test atsecurity/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java
Line 281 in 37afcaa
This is caused by the
irr.replace()
call in the special handling which resolves index patterns for theMultiGetRequest.Item
objects.The
indices:data/read/scroll
privilege is also required as index privilege, but any index will doNote: This might sound like a security issue first, but it is actually not, as the
indices:data/read/search
privileges are still effective to limit access.Like
indices:data/read/mget
, theindices:data/scroll
privileges need to be provided both ascluster_permissions
andindex_permissions
. The special handling forindices:data/scroll
also includes the attempt to gather the requested indices from the request. As the scroll request does not carry index information, the requested indices will be however assumed to be*
(all indices). ThesecurityRoles.reduce()
call will then calculate the intersection between*
and the indices with privileges and return all indices with available privileges. With these, theirr.replace()
method is called. This however is just a no-op for scroll requests:security/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java
Line 797 in 37afcaa
That means effectively, that a
indices:data/read/scroll
index privilege is necessary, but any non-empty set of indices is sufficient to satisfy the special handling code. While this is not a security issue, as there are further safe-guards (see above), this is an inconsistent behaviour.Proposed solution
The special handling code for
do_not_fail_on_forbidden
mode on cluster actions is actually unnecessary and can be completely removed.For the multi actions like
mget
,msearch
,mtv
, and search template actions, the action handling will always trigger sub-actions which will be routed again through the privilege evaluation code - then, the proper access controls will be enforced.For the scroll action, proper access control has been already enforced before when issuing the
search
request.Thus, the special handling code actually introduces no benefits and only issues.
The text was updated successfully, but these errors were encountered: