diff --git a/docs/changelog/127321.yaml b/docs/changelog/127321.yaml new file mode 100644 index 0000000000000..16191d9c34442 --- /dev/null +++ b/docs/changelog/127321.yaml @@ -0,0 +1,6 @@ +pr: 127321 +summary: Granting `kibana_system` reserved role access to "all" privileges to `.adhoc.alerts*` + and `.internal.adhoc.alerts*` indices +area: Authorization +type: enhancement +issues: [] diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java index 55e6b20546947..3c4b26a862563 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java @@ -265,6 +265,12 @@ static RoleDescriptor kibanaSystem(String name) { RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.ALERTS_INDEX_ALIAS).privileges("all").build(), // "Alerts as data" public index alias used in Security Solution // Kibana system user uses them to read / write alerts. + RoleDescriptor.IndicesPrivileges.builder() + .indices(ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX, ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS) + .privileges("create_index", "manage", "read", "write") + .build(), + // "Alerts as data" public index alias used in Security Solution + // Kibana system user uses them to read / write alerts. RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS).privileges("all").build(), // "Alerts as data" internal backing indices used in Security Solution // Kibana system user creates these indices; reads / writes to them via the diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java index 7251d233e25a9..52fe69c949a4b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java @@ -59,6 +59,10 @@ public class ReservedRolesStore implements BiConsumer, ActionListene public static final String PREVIEW_ALERTS_BACKING_INDEX = ".internal.preview.alerts*"; public static final String PREVIEW_ALERTS_BACKING_INDEX_REINDEXED = ".reindexed-v8-internal.preview.alerts*"; + /** "Attack Discovery" ad-hoc alerts index */ + public static final String ADHOC_ALERTS_INDEX_ALIAS = ".adhoc.alerts*"; + public static final String ADHOC_ALERTS_BACKING_INDEX = ".internal.adhoc.alerts*"; + /** "Security Solutions" only lists index for value lists for detections */ public static final String LISTS_INDEX = ".lists-*"; public static final String LISTS_INDEX_REINDEXED_V8 = ".reindexed-v8-lists-*"; @@ -782,7 +786,11 @@ private static RoleDescriptor buildViewerRoleDescriptor() { .build(), // Alerts-as-data RoleDescriptor.IndicesPrivileges.builder() - .indices(ReservedRolesStore.ALERTS_INDEX_ALIAS, ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS) + .indices( + ReservedRolesStore.ALERTS_INDEX_ALIAS, + ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS, + ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS + ) .privileges("read", "view_index_metadata") .build(), // Universal Profiling @@ -846,7 +854,9 @@ private static RoleDescriptor buildEditorRoleDescriptor() { ReservedRolesStore.ALERTS_INDEX_ALIAS, ReservedRolesStore.PREVIEW_ALERTS_BACKING_INDEX, ReservedRolesStore.PREVIEW_ALERTS_BACKING_INDEX_REINDEXED, - ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS + ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS, + ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX, + ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS ) .privileges("read", "view_index_metadata", "write", "maintenance") .build(), diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java index f8ac34ae4239f..2d16d210e089f 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java @@ -624,6 +624,17 @@ public void testKibanaSystemRole() { ".slo-observability." + randomAlphaOfLength(randomIntBetween(0, 13)) ).forEach(index -> assertAllIndicesAccessAllowed(kibanaRole, index)); + Arrays.asList( + ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS + randomAlphaOfLength(randomIntBetween(0, 13)), + ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX + randomAlphaOfLength(randomIntBetween(0, 13)) + ).forEach(index -> { + final IndexAbstraction indexAbstraction = mockIndexAbstraction(index); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true)); + assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportUpdateAction.TYPE.name()).test(indexAbstraction), is(true)); + assertViewIndexMetadata(kibanaRole, index); + }); + // read-only index access, including cross cluster Arrays.asList(".monitoring-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((index) -> { logger.info("index name [{}]", index);