Skip to content
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

Scrolling a remote index should not require cluster:monitor/state privilege #43974

Closed
droberts195 opened this issue Jul 4, 2019 · 2 comments · Fixed by #43991
Closed

Scrolling a remote index should not require cluster:monitor/state privilege #43974

droberts195 opened this issue Jul 4, 2019 · 2 comments · Fixed by #43991
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@droberts195
Copy link
Contributor

At the moment it seems that starting a scroll on a remote index requires just the index permissions you'd expect, but continuing that scroll involving a remote index additionally requires that you have permission to read the entire cluster state.

To demonstrate:

  1. Install two local single node clusters on your machine with security enabled: cluster 1 and cluster 2
  2. Configure cluster 1 as a remote of cluster 2
  3. Import some data into both clusters
  4. Create a role cluster_one_data in cluster 1 that gives all access to the index containing the imported data
  5. Create a role cluster_one_data in cluster 1 that gives all access to the remote index containing the imported data in cluster 1
  6. Create a role cluster_two_data in cluster 2 that gives all access to the index containing the imported data in cluster 2
  7. Create a user in cluster 2 with the following roles:
    a. kibana_user
    b. cluster_one_data
    c. cluster_two_data
  8. From cluster 2, try scrolling the local and remote data in both clusters using the newly created user:
POST /farequote/_search?scroll=1m

POST /_search/scroll
{
  "scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAALfEWZGhpcUxXeENST1dZRUZSMTF1T2Vidw==",
  "scroll" : "1m"
}

POST /cluster_one:farequote/_search?scroll=1m

POST /_search/scroll
{
  "scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAABvQiY2x1c3Rlcl9vbmU6Qm1hRFIzOWdRT0d1bjI5OV9hZE5zdw==",
  "scroll" : "1m"
}

(Obviously the exact scroll IDs will vary from run to run.)

You will note that the local scroll can be started and continued with just privileges on the index being scrolled. The scroll of the remote index can also be started successfully, returning the first few hits as expected. But the attempt to continue the remote scroll returns this:

{
  "error": {
    "root_cause": [
      {
        "type": "security_exception",
        "reason": "action [cluster:monitor/state] is unauthorized for user [dave]"
      }
    ],
    "type": "security_exception",
    "reason": "action [cluster:monitor/state] is unauthorized for user [dave]"
  },
  "status": 403
}

I think that if the remote scroll continuation needs to get some portion of the cluster state as an internal implementation detail then it should switch to system context to get this information, because logically you'd expect to be able to scroll an index when you have been granted permission to scroll that index. You should not additionally need permission to read the entire cluster state.

@droberts195 droberts195 added >bug :Search/Search Search-related issues that do not fall into other categories labels Jul 4, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@droberts195
Copy link
Contributor Author

I think the problem is in the RemoteClusterConnection class:

transportService.sendRequest(connection, ClusterStateAction.NAME, request, TransportRequestOptions.EMPTY,

I think that call to get the remote cluster state for the purpose of checking which nodes exist should be done in the system context, like in

droberts195 added a commit to droberts195/elasticsearch that referenced this issue Jul 4, 2019
When finding nodes in a connected cluster for cross cluster
search the requests to get cluster state on the connected
cluster should be made in the system context because
logically they are equivalent to checking a single detail
in the local cluster state and should not require that the
user who made the request that is using this method in its
implementation is authorized to view the entire cluster
state.

Fixes elastic#43974
pull bot pushed a commit to rogues-gallery/elasticsearch that referenced this issue Jul 23, 2019
When finding nodes in a connected cluster for cross cluster
search the requests to get cluster state on the connected
cluster should be made in the system context because
logically they are equivalent to checking a single detail
in the local cluster state and should not require that the
user who made the request that is using this method in its
implementation is authorized to view the entire cluster
state.

Fixes elastic#43974
polyfractal pushed a commit to polyfractal/elasticsearch that referenced this issue Jul 29, 2019
When finding nodes in a connected cluster for cross cluster
search the requests to get cluster state on the connected
cluster should be made in the system context because
logically they are equivalent to checking a single detail
in the local cluster state and should not require that the
user who made the request that is using this method in its
implementation is authorized to view the entire cluster
state.

Fixes elastic#43974
droberts195 added a commit that referenced this issue Jul 31, 2019
When finding nodes in a connected cluster for cross cluster
search the requests to get cluster state on the connected
cluster should be made in the system context because
logically they are equivalent to checking a single detail
in the local cluster state and should not require that the
user who made the request that is using this method in its
implementation is authorized to view the entire cluster
state.

Fixes #43974
droberts195 added a commit that referenced this issue Jul 31, 2019
When finding nodes in a connected cluster for cross cluster
search the requests to get cluster state on the connected
cluster should be made in the system context because
logically they are equivalent to checking a single detail
in the local cluster state and should not require that the
user who made the request that is using this method in its
implementation is authorized to view the entire cluster
state.

Fixes #43974
droberts195 added a commit that referenced this issue Jul 31, 2019
When finding nodes in a connected cluster for cross cluster
search the requests to get cluster state on the connected
cluster should be made in the system context because
logically they are equivalent to checking a single detail
in the local cluster state and should not require that the
user who made the request that is using this method in its
implementation is authorized to view the entire cluster
state.

Fixes #43974
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants