Skip to content

Commit 46529f0

Browse files
spongbanderror
andauthored
Granting kibana_system reserved role access to all privileges to .internal.alerts* (#76624) (#76635)
**Parent ticket:** elastic/kibana#101016 **Related to:** #72181 ## Summary Similar to the previous PR (#72181), we'd like to add privileges to a new set of indices to the `kibana_system` role. The reason for that is we need to have different naming schemes for alerts-as-data index aliases and backing indices pointing to these aliases, which in turn is needed to support backwards compatibility, migrations and reindexing in the future. We didn't want to prefix the backing indices with `.kibana-`, so we're adding a new `.internal.alerts` prefix. Prefixing with `.kibana-` would make them system indices, which means they would not be supposed to be read by end users, which is not what we want. `.internal` could become a universal prefix for hidden Kibana indices, but at this point I don't feel confident enough to generalise prematurely. Co-authored-by: Georgii Gorbachev <banderror@gmail.com>
1 parent 608aced commit 46529f0

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
import java.util.stream.Collectors;
3838

3939
public class ReservedRolesStore implements BiConsumer<Set<String>, ActionListener<RoleRetrievalResult>> {
40-
public static final String LEGACY_ALERTS_INDEX = ".siem-signals*";
41-
public static final String ALERTS_INDEX = ".alerts*";
40+
public static final String ALERTS_LEGACY_INDEX = ".siem-signals*";
41+
public static final String ALERTS_BACKING_INDEX = ".internal.alerts*";
42+
public static final String ALERTS_INDEX_ALIAS = ".alerts*";
4243

4344
public static final RoleDescriptor SUPERUSER_ROLE_DESCRIPTOR = new RoleDescriptor("superuser",
4445
new String[] { "all" },
@@ -422,15 +423,20 @@ public static RoleDescriptor kibanaSystemRoleDescriptor(String name) {
422423
RoleDescriptor.IndicesPrivileges.builder()
423424
.indices(".fleet*")
424425
.privileges("all").build(),
425-
// Legacy "Alerts as data" index. Kibana user will create this index.
426-
// Kibana user will read / write to these indices
426+
// Legacy "Alerts as data" used in Security Solution.
427+
// Kibana user creates these indices; reads / writes to them.
427428
RoleDescriptor.IndicesPrivileges.builder()
428-
.indices(ReservedRolesStore.LEGACY_ALERTS_INDEX)
429+
.indices(ReservedRolesStore.ALERTS_LEGACY_INDEX)
429430
.privileges("all").build(),
430-
// "Alerts as data" index. Kibana user will create this index.
431-
// Kibana user will read / write to these indices
431+
// "Alerts as data" internal backing indices used in Security Solution, Observability, etc.
432+
// Kibana system user creates these indices; reads / writes to them via the aliases (see below).
432433
RoleDescriptor.IndicesPrivileges.builder()
433-
.indices(ReservedRolesStore.ALERTS_INDEX)
434+
.indices(ReservedRolesStore.ALERTS_BACKING_INDEX)
435+
.privileges("all").build(),
436+
// "Alerts as data" public index aliases used in Security Solution, Observability, etc.
437+
// Kibana system user uses them to read / write alerts.
438+
RoleDescriptor.IndicesPrivileges.builder()
439+
.indices(ReservedRolesStore.ALERTS_INDEX_ALIAS)
434440
.privileges("all").build(),
435441
// Endpoint / Fleet policy responses. Kibana requires read access to send telemetry
436442
RoleDescriptor.IndicesPrivileges.builder()

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,9 @@ public void testKibanaSystemRole() {
404404
".reporting-" + randomAlphaOfLength(randomIntBetween(0, 13)),
405405
".apm-agent-configuration",
406406
".apm-custom-link",
407-
ReservedRolesStore.LEGACY_ALERTS_INDEX + randomAlphaOfLength(randomIntBetween(0, 13)),
408-
ReservedRolesStore.ALERTS_INDEX + randomAlphaOfLength(randomIntBetween(0, 13))
407+
ReservedRolesStore.ALERTS_LEGACY_INDEX + randomAlphaOfLength(randomIntBetween(0, 13)),
408+
ReservedRolesStore.ALERTS_BACKING_INDEX + randomAlphaOfLength(randomIntBetween(0, 13)),
409+
ReservedRolesStore.ALERTS_INDEX_ALIAS + randomAlphaOfLength(randomIntBetween(0, 13))
409410
).forEach((index) -> {
410411
logger.info("index name [{}]", index);
411412
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(mockIndexAbstraction(index)), is(true));

0 commit comments

Comments
 (0)