Skip to content

Commit 8799115

Browse files
e40pudelasticsearchmachine
andauthored
[8.19] Granting kibana_system reserved role access to "all" privileges to .adhoc.alerts* and .internal.adhoc.alerts* indices (elastic#127321) (elastic#128831)
* Granting `kibana_system` reserved role access to "all" privileges to `.adhoc.alerts*` and `.internal.adhoc.alerts*` indices (elastic#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]> * Fix CI --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent 1eae10d commit 8799115

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction;
1111
import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction;
12+
import org.elasticsearch.action.admin.indices.mapping.put.TransportAutoPutMappingAction;
1213
import org.elasticsearch.action.admin.indices.mapping.put.TransportPutMappingAction;
1314
import org.elasticsearch.action.admin.indices.rollover.RolloverAction;
1415
import org.elasticsearch.action.admin.indices.settings.put.TransportUpdateSettingsAction;
@@ -256,6 +257,23 @@ static RoleDescriptor kibanaSystem(String name) {
256257
RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.ALERTS_INDEX_ALIAS).privileges("all").build(),
257258
// "Alerts as data" public index alias used in Security Solution
258259
// Kibana system user uses them to read / write alerts.
260+
RoleDescriptor.IndicesPrivileges.builder()
261+
.indices(ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX, ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS)
262+
.privileges(
263+
"create_index",
264+
"read",
265+
"write",
266+
"view_index_metadata",
267+
"maintenance",
268+
RolloverAction.NAME,
269+
TransportIndicesAliasesAction.NAME,
270+
TransportPutMappingAction.TYPE.name(),
271+
TransportAutoPutMappingAction.TYPE.name(),
272+
TransportUpdateSettingsAction.TYPE.name()
273+
)
274+
.build(),
275+
// "Alerts as data" public index alias used in Security Solution
276+
// Kibana system user uses them to read / write alerts.
259277
RoleDescriptor.IndicesPrivileges.builder().indices(ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS).privileges("all").build(),
260278
// "Alerts as data" internal backing indices used in Security Solution
261279
// 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
@@ -60,6 +60,10 @@ public class ReservedRolesStore implements BiConsumer<Set<String>, ActionListene
6060
public static final String PREVIEW_ALERTS_BACKING_INDEX = ".internal.preview.alerts*";
6161
public static final String PREVIEW_ALERTS_BACKING_INDEX_REINDEXED = ".reindexed-v8-internal.preview.alerts*";
6262

63+
/** "Attack Discovery" ad-hoc alerts index */
64+
public static final String ADHOC_ALERTS_INDEX_ALIAS = ".adhoc.alerts*";
65+
public static final String ADHOC_ALERTS_BACKING_INDEX = ".internal.adhoc.alerts*";
66+
6367
/** "Security Solutions" only lists index for value lists for detections */
6468
public static final String LISTS_INDEX = ".lists-*";
6569
public static final String LISTS_INDEX_REINDEXED_V8 = ".reindexed-v8-lists-*";
@@ -894,7 +898,11 @@ private static RoleDescriptor buildViewerRoleDescriptor() {
894898
.build(),
895899
// Alerts-as-data
896900
RoleDescriptor.IndicesPrivileges.builder()
897-
.indices(ReservedRolesStore.ALERTS_INDEX_ALIAS, ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS)
901+
.indices(
902+
ReservedRolesStore.ALERTS_INDEX_ALIAS,
903+
ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS,
904+
ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS
905+
)
898906
.privileges("read", "view_index_metadata")
899907
.build(),
900908
// Universal Profiling
@@ -958,7 +966,9 @@ private static RoleDescriptor buildEditorRoleDescriptor() {
958966
ReservedRolesStore.ALERTS_INDEX_ALIAS,
959967
ReservedRolesStore.PREVIEW_ALERTS_BACKING_INDEX,
960968
ReservedRolesStore.PREVIEW_ALERTS_BACKING_INDEX_REINDEXED,
961-
ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS
969+
ReservedRolesStore.PREVIEW_ALERTS_INDEX_ALIAS,
970+
ReservedRolesStore.ADHOC_ALERTS_BACKING_INDEX,
971+
ReservedRolesStore.ADHOC_ALERTS_INDEX_ALIAS
962972
)
963973
.privileges("read", "view_index_metadata", "write", "maintenance")
964974
.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
@@ -626,6 +626,31 @@ public void testKibanaSystemRole() {
626626
".slo-observability." + randomAlphaOfLength(randomIntBetween(0, 13))
627627
).forEach(index -> assertAllIndicesAccessAllowed(kibanaRole, index));
628628

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

0 commit comments

Comments
 (0)