Skip to content

Commit 550cddf

Browse files
e40pudelasticsearchmachine
andauthored
Granting kibana_system reserved role access to "all" privileges to .adhoc.alerts* and .internal.adhoc.alerts* indices (#127321)
* Granting `kibana_system` reserved role access to "all" privileges to `.adhoc.alerts*` and `.internal.adhoc.alerts*` indices * Update docs/changelog/127321.yaml * [CI] Auto commit changes from spotless * Replace `"all"` with the specific privileges for the `kibana_system` role * Fix tests * Fix CI * Updated privileges * Updated privileges Add `"maintenance"` to allow `refresh=true` option on bulk API call. * Remove redundant code --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent 38fb46d commit 550cddf

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

docs/changelog/127321.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 127321
2+
summary: Granting `kibana_system` reserved role access to "all" privileges to `.adhoc.alerts*`
3+
and `.internal.adhoc.alerts*` indices
4+
area: Authorization
5+
type: enhancement
6+
issues: []

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,23 @@ static RoleDescriptor kibanaSystem(String name) {
265265
RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.ALERTS_INDEX_ALIAS).privileges("all").build(),
266266
// "Alerts as data" public index alias used in Security Solution
267267
// Kibana system user uses them to read / write alerts.
268+
RoleDescriptor.IndicesPrivileges.builder()
269+
.indices(ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX, ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS)
270+
.privileges(
271+
"create_index",
272+
"read",
273+
"write",
274+
"view_index_metadata",
275+
"maintenance",
276+
RolloverAction.NAME,
277+
TransportIndicesAliasesAction.NAME,
278+
TransportPutMappingAction.TYPE.name(),
279+
TransportAutoPutMappingAction.TYPE.name(),
280+
TransportUpdateSettingsAction.TYPE.name()
281+
)
282+
.build(),
283+
// "Alerts as data" public index alias used in Security Solution
284+
// Kibana system user uses them to read / write alerts.
268285
RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS).privileges("all").build(),
269286
// "Alerts as data" internal backing indices used in Security Solution
270287
// Kibana system user creates these indices; reads / writes to them via the

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public class ReservedRolesStore implements BiConsumer<Set<String>, ActionListene
5959
public static final String PREVIEW_ALERTS_BACKING_INDEX = ".internal.preview.alerts*";
6060
public static final String PREVIEW_ALERTS_BACKING_INDEX_REINDEXED = ".reindexed-v8-internal.preview.alerts*";
6161

62+
/** "Attack Discovery" ad-hoc alerts index */
63+
public static final String ADHOC_ALERTS_INDEX_ALIAS = ".adhoc.alerts*";
64+
public static final String ADHOC_ALERTS_BACKING_INDEX = ".internal.adhoc.alerts*";
65+
6266
/** "Security Solutions" only lists index for value lists for detections */
6367
public static final String LISTS_INDEX = ".lists-*";
6468
public static final String LISTS_INDEX_REINDEXED_V8 = ".reindexed-v8-lists-*";
@@ -782,7 +786,11 @@ private static RoleDescriptor buildViewerRoleDescriptor() {
782786
.build(),
783787
// Alerts-as-data
784788
RoleDescriptor.IndicesPrivileges.builder()
785-
.indices(ReservedRolesStore.ALERTS_INDEX_ALIAS, ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS)
789+
.indices(
790+
ReservedRolesStore.ALERTS_INDEX_ALIAS,
791+
ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS,
792+
ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS
793+
)
786794
.privileges("read", "view_index_metadata")
787795
.build(),
788796
// Universal Profiling
@@ -846,7 +854,9 @@ private static RoleDescriptor buildEditorRoleDescriptor() {
846854
ReservedRolesStore.ALERTS_INDEX_ALIAS,
847855
ReservedRolesStore.PREVIEW_ALERTS_BACKING_INDEX,
848856
ReservedRolesStore.PREVIEW_ALERTS_BACKING_INDEX_REINDEXED,
849-
ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS
857+
ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS,
858+
ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX,
859+
ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS
850860
)
851861
.privileges("read", "view_index_metadata", "write", "maintenance")
852862
.build(),

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,31 @@ public void testKibanaSystemRole() {
624624
".slo-observability." + randomAlphaOfLength(randomIntBetween(0, 13))
625625
).forEach(index -> assertAllIndicesAccessAllowed(kibanaRole, index));
626626

627+
Arrays.asList(
628+
ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS + randomAlphaOfLength(randomIntBetween(0, 13)),
629+
ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX + randomAlphaOfLength(randomIntBetween(0, 13))
630+
).forEach(index -> {
631+
final IndexAbstraction indexAbstraction = mockIndexAbstraction(index);
632+
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
633+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction), is(true));
634+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndicesAliasesAction.NAME).test(indexAbstraction), is(true));
635+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportPutMappingAction.TYPE.name()).test(indexAbstraction), is(true));
636+
assertThat(
637+
kibanaRole.indices().allowedIndicesMatcher(TransportAutoPutMappingAction.TYPE.name()).test(indexAbstraction),
638+
is(true)
639+
);
640+
assertThat(
641+
kibanaRole.indices().allowedIndicesMatcher(TransportUpdateSettingsAction.TYPE.name()).test(indexAbstraction),
642+
is(true)
643+
);
644+
645+
// Check view_index_metadata privilege
646+
assertViewIndexMetadata(kibanaRole, index);
647+
648+
// Check read, write and maintenance privileges
649+
assertReadWriteDocsAndMaintenanceButNotDeleteIndexAllowed(kibanaRole, index + randomIntBetween(0, 5));
650+
});
651+
627652
// read-only index access, including cross cluster
628653
Arrays.asList(".monitoring-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((index) -> {
629654
logger.info("index name [{}]", index);

0 commit comments

Comments
 (0)