Skip to content

Remove implicit index monitor privilege #37774

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

Conversation

albertzaharovits
Copy link
Contributor

Follow-up on #37577 (comment)

Restricted indices (currently only .security-6 and .security) are special internal
indices that require setting the allow_restricted_indices flag on every index
permission that covers them. If this flag is false (default) the permission
will not cover these and actions against them will not be authorized.
However, the monitoring APIs were the only exception to this rule.

This exception is herein forfeited and index monitoring privileges have to be
granted explicitly, using the allow_restricted_indices flag on the permission,
as is the case for any other index privilege.

@albertzaharovits albertzaharovits added >breaking v7.0.0 :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC labels Jan 23, 2019
@albertzaharovits albertzaharovits self-assigned this Jan 23, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@albertzaharovits
Copy link
Contributor Author

albertzaharovits commented Jan 23, 2019

https://elasticsearch-ci.elastic.co/job/elastic+elasticsearch+pull-request-1/5678/consoleFull

20:43:26 org.elasticsearch.gradle.BuildExamplePluginsIT > testCurrentExamplePlugin {p0=/var/lib/jenkins/workspace/elastic+elasticsearch+pull-request-1/plugins/examples/custom-suggester} FAILED

@elasticmachine run elasticsearch-ci/1

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

Overall the changes look good. One thing I'd like to see though is a integration test with monitoring APIs that relate to indices and ensuring that they work if the user doesn't specify a specific index and does not have allow restricted indices set to true. During wildcard resolution we should be filtering out the indices without permissions but I think there were some APIs where we couldn't do that.

@albertzaharovits
Copy link
Contributor Author

@jaymode Hey Jay, I have added the Integ Test for the index monitoring priv, but I have not noticed anything fishy. Can you take a another look please?

.endObject());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());

refresh();
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to make sure the internal security indices are created here. Maybe we create a user and a role and validate that the security indices exist

Copy link
Member

Choose a reason for hiding this comment

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

We'll also want to look at testing the cluster health api at the indices and shards levels. Same for the cluster stats api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cluster Health and Stats are authorized as cluster actions cluster:monitor/* and will see all indices irrespective of the change proposed here.

Copy link
Member

Choose a reason for hiding this comment

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

I went back into the time machine and figured out the API that this leniency for monitoring came from. It is the _cat/indices API. I am pretty sure it will still fail based on the way it works so I think we should:

  1. add a test and validate cat indices will cause issues if the security index exists and the user is not allowed access
  2. find a fix

Copy link
Contributor Author

@albertzaharovits albertzaharovits Jan 28, 2019

Choose a reason for hiding this comment

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

We dug into this over slack.
Jay pointed me to the commit that added this leniency and we identified that it was no longer relevant as the cause got inadvertently removed by #18545 .
As discussed, I have added a test for _cat/indices/* to validate that no unauthorized exception is thrown (when the wildcard includes the unauthorized .security index).

@@ -127,6 +141,64 @@ public void testSingleRole() throws Exception {
assertHitCount(searchResponse, 1);
}

public void testMonitorRestrictedWildcards() throws Exception {

assertSecurityIndexActive();
Copy link
Member

Choose a reason for hiding this comment

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

unfortunately this does not do what you want it to do. This will pass if the index does not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@albertzaharovits
Copy link
Contributor Author

@jaymode I got this in the state we talked about. May you take a look, please?

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

@albertzaharovits
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/1

2 similar comments
@albertzaharovits
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/1

@albertzaharovits
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/1

@albertzaharovits
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

1 similar comment
@albertzaharovits
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

@albertzaharovits
Copy link
Contributor Author

🎲 @elasticmachine run elasticsearch-ci/1

@albertzaharovits
Copy link
Contributor Author

🎲 @elasticmachine run elasticsearch-ci/2

@albertzaharovits albertzaharovits merged commit 697b2fb into elastic:master Jan 29, 2019
@albertzaharovits albertzaharovits deleted the remove_implicit_monitor_privilege branch January 29, 2019 19:10
@albertzaharovits albertzaharovits mentioned this pull request Apr 16, 2019
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants