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

Allow access to restricted system indices for reserved system roles #76845

Conversation

williamrandolph
Copy link
Contributor

@williamrandolph williamrandolph commented Aug 23, 2021

After we merged #74212 , the Kibana team saw permissions errors at startup.

The cause of this is that all system indices are now restricted indices from the perspective of security, when previously the only restricted indices were security and async search indices. In that PR, we didn't update the reserved system roles so that the ones that access system indices have allowRestrictedIndices = true.

We can find the roles that need this change by adding system index patterns to the TestRestrictedIndices class and looking for failures in ReservedRolesStoreTests.

The fixes for the particular kibana issue are the updates to the kibana_system role.

@williamrandolph williamrandolph added :Core/Infra/Core Core issues without another label :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC v8.0.0 labels Aug 23, 2021
@elasticmachine elasticmachine added Team:Core/Infra Meta label for core/infra team Team:Security Meta label for security team labels Aug 23, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@tylersmalley
Copy link
Contributor

tylersmalley commented Aug 24, 2021

I verified this resolved the startup issue we're seeing with the promotion of the nightly snapshot for Kibana.

Comment on lines 397 to 399
.indices("*")
.privileges("view_index_metadata", "monitor").build(),
.privileges("view_index_metadata", "monitor")
.allowRestrictedIndices(true).build(),
Copy link
Member

Choose a reason for hiding this comment

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

This change allows the kibana_system user to have some access to the .security index. I don't think this is what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went through the list of system indices and pared down where I was allowing restricted indices to just the places where we are dealing with system indices, so I hope I've addressed this concern.

Copy link
Member

Choose a reason for hiding this comment

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

Yes the change addressed my previous comment, thanks. But we still have another semantic change: before the #74212, this index privilege allow kibana to monitor and view_index_metadata for indices like .watches, .triggered_watches. These indices are now no longer accessible for kibana_system. Maybe this is the right thing to do. But I'd like to double check whether this is intentional.

@tvernum
Copy link
Contributor

tvernum commented Aug 24, 2021

It looks to me like this issue slipped through because TestRestrictedIndices only contains security and async search indices.

Can we update it to include the complete set of out-of-the-box system indices?

A missing piece in elastic#74212 was system index patterns in the tests for the
ReservedRolesStore. Without these patterns, the tests did not accurately
check whether a role was incorrectly accessing a system index that was
not previously a restricted index.

This commit adds all of the current system index patterns to the test
class and adds restricted index access to the system roles that need it
for tests to pass.
@williamrandolph
Copy link
Contributor Author

@tvernum

Thanks for the pointer. I think that is exactly the issue. I've manually added all the system index patterns to the TestRestrictedIndices class. I would really like to refactor this work so that we are referencing the actual string constants that the system index plugins use, but I think there's a good argument for pushing that to a follow-up and merging a fix for the Kibana team as soon as possible so that they can update their Elasticsearch snapshots.

@williamrandolph williamrandolph changed the title Broadly allow access to restricted indices from the Kibana role Allow access to restricted system indices for reserved system roles Aug 25, 2021
Comment on lines 397 to 399
.indices("*")
.privileges("view_index_metadata", "monitor").build(),
.privileges("view_index_metadata", "monitor")
.allowRestrictedIndices(true).build(),
Copy link
Member

Choose a reason for hiding this comment

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

Yes the change addressed my previous comment, thanks. But we still have another semantic change: before the #74212, this index privilege allow kibana to monitor and view_index_metadata for indices like .watches, .triggered_watches. These indices are now no longer accessible for kibana_system. Maybe this is the right thing to do. But I'd like to double check whether this is intentional.

Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

The way how privileges are granted to restricted indices feels brittle to me. It requires checking and matching names from different places carefully (as well as adding them to tests). But maybe it is because this PR is a one-time mass update. It may feel alright for future smaller changes. Also I don't have a good suggestion for alternatives.

I think we need a conclusion on kibana_system's monitor and view_index_metadata access for *. Should we strictly maintain the previous semantic or are we ok to change? I am ok either way as long as we are conscious on the decision. Thanks!

@williamrandolph
Copy link
Contributor Author

@ywangd In the XPackUser class, we have a pattern that allows access to all indices except for ones that begin with .security or .async-search. I've borrowed that pattern for use here, in order to preserve existing behavior.

I think it could be argued that we should exclude other system indices from data telemetry, but I'm not sure about that, and I don't want it to hold up getting this merged.

@williamrandolph
Copy link
Contributor Author

@elasticmachine test this please

Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

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

LGTM

I think it could be argued that we should exclude other system indices from data telemetry

I tend to agree especially this change is 8.0 only. But I am not familiar with all system indices and how they should be surfaced by Kibana. I think it needs input from people who are more familiar with its usage (maybe a round of emails?). For this PR, I think maintaining the exact same semantic is the safest.

Can I also suggest we add a few more assertions about kibana_system cannot view metadata or monitor .security* and .async-search*? The current assertions only ensure no read or write access to the indices, but not metadata level access. I think this is also why the test didn't tripped on the first version of this PR.

@williamrandolph
Copy link
Contributor Author

@ywangd Thank you for the review and for the final suggestion about checking the metadata privileges. I've added the test for it.

@tylersmalley I'll be letting tests run overnight and merging this first thing tomorrow. Apologies for the delays.

@tvernum
Copy link
Contributor

tvernum commented Aug 26, 2021

I think it could be argued that we should exclude other system indices from data telemetry

I tend to agree especially this change is 8.0 only. But I am not familiar with all system indices and how they should be surfaced by Kibana. I think it needs input from people who are more familiar with its usage (maybe a round of emails?). For this PR, I think maintaining the exact same semantic is the safest.

I think there is where we should end up.
If Kibana needs to monitor system indices, we can have that conversation, but I don't think we should start on that assumption.

@williamrandolph williamrandolph merged commit 8759c85 into elastic:master Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Core/Infra Meta label for core/infra team Team:Security Meta label for security team v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants