Skip to content

[ResponseOps] Granting kibana_system role access to the cases analytics indices #129414

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

adcoelho
Copy link

Summary

The ResponseOps team is currently working on creating(and populating) dedicated cases analytics indexes during Kibana startup.

This is the feature branch draft PR for reference.

The Kibana System role did not have the privileges needed for this, so in this PR, I added the following:

  • .internal.cases*: all - so that the cases analytics indexes can be created/updated/deleted
  • cluster:admin/script/put + cluster:admin/script/get - our logic for synchronizing the indexes with the cases' index requires the usage of painless scripts that need to be fetched and updated.

@adcoelho adcoelho requested review from azasypkin and cnasikas June 13, 2025 13:28
@adcoelho adcoelho self-assigned this Jun 13, 2025
@adcoelho adcoelho requested a review from a team as a code owner June 13, 2025 13:28
@adcoelho adcoelho added :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC auto-backport Automatically create backport pull requests when merged v9.1.0 labels Jun 13, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Jun 13, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@adcoelho adcoelho force-pushed the cases-analytics-index branch from 404f1a9 to c0fcec1 Compare June 13, 2025 14:53
@adcoelho adcoelho force-pushed the cases-analytics-index branch from c0fcec1 to bc4a819 Compare June 13, 2025 14:56
adcoelho added a commit to elastic/kibana that referenced this pull request Jun 17, 2025
**Merging into a feature branch**

## Summary

This PR adds the `.internal.cases-activity` analytics index.

## How to test

1. Add `xpack.cases.analytics.index.enabled: true` to `kibana.dev.yml`
2. Check out [this
branch](elastic/elasticsearch#129414) from the
ES project.
3. Start Elastic Search with `yarn es source`.
4. Add a bunch of activity to your cases. Edit tags, category, etc.
5. Go to the dev tools and confirm this activity shows up in the index -
`GET /.internal.cases-activity/_search`.
@azasypkin
Copy link
Member

@elasticmachine update branch

elasticmachine and others added 2 commits June 18, 2025 10:18
Create constants for indexes and aliases.
Update tests.
@adcoelho adcoelho requested a review from a team as a code owner June 18, 2025 10:07
@cnasikas cnasikas changed the title [ResponseOps] Update Kibana System Role [ResponseOps] Granting kibana_system reserved role access to the cases analytics indices Jun 18, 2025
@cnasikas cnasikas changed the title [ResponseOps] Granting kibana_system reserved role access to the cases analytics indices [ResponseOps] Granting kibana_system role access to the cases analytics indices Jun 18, 2025
Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

The change is aligned with what has been discussed in the relevant RFC and hence LGTM.

I see the scripts we store are static/const, do we plan to compose these scripts dynamically in the near future?

If no, I have a question for @elastic/es-security: is there any precedent where we define a painless script used by some Elastic Stack component (e.g., Kibana) directly in ES so that we don't need to grant cluster:admin/script/put to a service system account to store such a "predefined" script?

@adcoelho
Copy link
Author

I see the scripts we store are static/const, do we plan to compose these scripts dynamically in the near future?

The scripts are created statically, but our logic relies on the capacity to create new scripts to handle different Kibana nodes writing to these indexes concurrently.

is there any precedent where we define a painless script used by some Elastic Stack component (e.g., Kibana) directly in ES

If I get your suggestion correctly, this would also complicate our deployment process whenever we want to update mappings and scripts.

@azasypkin
Copy link
Member

If I get your suggestion correctly, this would also complicate our deployment process whenever we want to update mappings and scripts.

Assuming it's possible in principle to have predefined scripts in ES, it'd make changes a bit more involved (would require a PR against the ES repo), yes, but I'm not sure if it complicates anything, to be honest, as you won't need to worry about this at Kibana startup and can assume that any given ES version already has the script with the content and ID you need for this version.

That being said, not saying it's better or worse, just exploring alternatives.

@cnasikas
Copy link
Member

Thanks @azasypkin for the review and the feedback! To be honest, I am not sure if we will compose the scripts dynamically in the future. We may need to. Aside from that, the sync tasks will have some recovery mechanism to recreate the scripts in case of a catastrophic failure (user tampered with them, for example). We would need the scripts to be part of Kibana to do that, so they can recreate them unless it is implemented on the ES side. Also, when a Kibana node updates the mappings, it also updates the scripts. There is a one-to-one correspondence between the mapping and the scripts. Coordinating ES PRs with Kibana PRs may be challenging. Lastly, I am not sure how ownership works in ES and what the review process is. Do you mind if we move forward with this PR (unless there are security concerns) and explore alternatives after FF? I am open to discussing and seeing what approach makes more sense.

@slobodanadamovic slobodanadamovic requested review from slobodanadamovic and removed request for a team June 19, 2025 08:41
@azasypkin
Copy link
Member

azasypkin commented Jun 19, 2025

Lastly, I am not sure how ownership works in ES and what the review process is.

Same as in Kibana :) For example, AppEx Security co-owns a role definition for the Kibana System user in Elasticsearch and handles reviews, and you'd co-own script definitions (again, if it's possible to do something like this at all - i.e., having ability to define a "built-in/system" script that users cannot mess up with).

Do you mind if we move forward with this PR (unless there are security concerns) and explore alternatives after FF?

Definitely, I've approved the PR, meaning that's not a blocking suggestion, but more of a thing we could potentially explore now or in the future (assuming it has enough benefits from functional, maintenance, and security standpoints).

@cnasikas
Copy link
Member

Thanks @azasypkin! Yes, let's explore the alternatives. I would love that.

Comment on lines +103 to +104
"cluster:admin/script/put",
"cluster:admin/script/get",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: You can reference actual action constants here.

Suggested change
"cluster:admin/script/put",
"cluster:admin/script/get",
TransportPutStoredScriptAction.TYPE.name(),
GetStoredScriptAction.NAME,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >non-issue :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants