Skip to content

Commit d8bcbb6

Browse files
authored
[Security Solution] Add create_index to kibana_system role for Elastic Defend indices (#115241)
Adds create_index privilege to the kibana_system role for Elastic Defend internal indices Indices: ``` .logs-endpoint.heartbeat-* .logs-endpoint.diagnostic.collection-* .logs-endpoint.action.responses-* ```
1 parent f04bf5c commit d8bcbb6

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

docs/changelog/115241.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 115241
2+
summary: "[Security Solution] Add `create_index` to `kibana_system` role for index/DS\
3+
\ `.logs-endpoint.action.responses-*`"
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: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@ static RoleDescriptor kibanaSystem(String name) {
152152
// Data telemetry reads mappings, metadata and stats of indices
153153
RoleDescriptor.IndicesPrivileges.builder().indices("*").privileges("view_index_metadata", "monitor").build(),
154154
// Endpoint diagnostic information. Kibana reads from these indices to send
155-
// telemetry
156-
RoleDescriptor.IndicesPrivileges.builder().indices(".logs-endpoint.diagnostic.collection-*").privileges("read").build(),
155+
// telemetry and also creates the index when policies are first created
156+
RoleDescriptor.IndicesPrivileges.builder()
157+
.indices(".logs-endpoint.diagnostic.collection-*")
158+
.privileges("read", "create_index")
159+
.build(),
157160
// Fleet secrets. Kibana can only write to this index.
158161
RoleDescriptor.IndicesPrivileges.builder()
159162
.indices(".fleet-secrets*")
@@ -277,17 +280,19 @@ static RoleDescriptor kibanaSystem(String name) {
277280
)
278281
.build(),
279282
// Endpoint specific action responses. Kibana reads and writes (for third party
280-
// agents) to the index
281-
// to display action responses to the user.
283+
// agents) to the index to display action responses to the user.
284+
// `create_index`: is necessary in order to ensure that the DOT datastream index is
285+
// created by Kibana in order to avoid errors on the Elastic Defend side when streaming
286+
// documents to it.
282287
RoleDescriptor.IndicesPrivileges.builder()
283288
.indices(".logs-endpoint.action.responses-*")
284-
.privileges("auto_configure", "read", "write")
289+
.privileges("auto_configure", "read", "write", "create_index")
285290
.build(),
286291
// Endpoint specific actions. Kibana reads and writes to this index to track new
287292
// actions and display them.
288293
RoleDescriptor.IndicesPrivileges.builder()
289294
.indices(".logs-endpoint.actions-*")
290-
.privileges("auto_configure", "read", "write")
295+
.privileges("auto_configure", "read", "write", "create_index")
291296
.build(),
292297
// Legacy Osquery manager specific action responses. Kibana reads from these to
293298
// display responses to the user.
@@ -475,7 +480,7 @@ static RoleDescriptor kibanaSystem(String name) {
475480
RoleDescriptor.IndicesPrivileges.builder().indices(".slo-observability.*").privileges("all").build(),
476481
// Endpoint heartbeat. Kibana reads from these to determine metering/billing for
477482
// endpoints.
478-
RoleDescriptor.IndicesPrivileges.builder().indices(".logs-endpoint.heartbeat-*").privileges("read").build(),
483+
RoleDescriptor.IndicesPrivileges.builder().indices(".logs-endpoint.heartbeat-*").privileges("read", "create_index").build(),
479484
// For connectors telemetry. Will be removed once we switched to connectors API
480485
RoleDescriptor.IndicesPrivileges.builder().indices(".elastic-connectors*").privileges("read").build() },
481486
null,

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ public void testKibanaSystemRole() {
801801
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(mockIndexAbstraction(index)), is(true));
802802
assertThat(
803803
kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(mockIndexAbstraction(index)),
804-
is(false)
804+
is(true)
805805
);
806806
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(false));
807807
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(false));
@@ -949,7 +949,7 @@ public void testKibanaSystemRole() {
949949
);
950950
});
951951

952-
// read-only index for Endpoint and Osquery manager specific action responses
952+
// Elastic Defend internal index for response actions results
953953
Arrays.asList(".logs-endpoint.action.responses-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((index) -> {
954954
final IndexAbstraction indexAbstraction = mockIndexAbstraction(index);
955955
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false));
@@ -959,10 +959,7 @@ public void testKibanaSystemRole() {
959959
is(false)
960960
);
961961
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true));
962-
assertThat(
963-
kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction),
964-
is(false)
965-
);
962+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction), is(true));
966963
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true));
967964
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(true));
968965
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true));
@@ -1069,10 +1066,7 @@ public void testKibanaSystemRole() {
10691066
is(false)
10701067
);
10711068
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true));
1072-
assertThat(
1073-
kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction),
1074-
is(false)
1075-
);
1069+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction), is(true));
10761070
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(true));
10771071
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(true));
10781072
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true));
@@ -1097,10 +1091,7 @@ public void testKibanaSystemRole() {
10971091
is(false)
10981092
);
10991093
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true));
1100-
assertThat(
1101-
kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction),
1102-
is(false)
1103-
);
1094+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction), is(true));
11041095
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false));
11051096
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false));
11061097
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true));
@@ -1319,12 +1310,21 @@ public void testKibanaSystemRole() {
13191310

13201311
final boolean isAlsoAutoCreateIndex = indexName.startsWith(".logs-endpoint.actions-")
13211312
|| indexName.startsWith(".logs-endpoint.action.responses-");
1313+
1314+
final boolean isAlsoCreateIndex = indexName.startsWith(".logs-endpoint.actions-")
1315+
|| indexName.startsWith(".logs-endpoint.action.responses-")
1316+
|| indexName.startsWith(".logs-endpoint.diagnostic.collection-")
1317+
|| indexName.startsWith(".logs-endpoint.heartbeat-");
1318+
13221319
assertThat(
13231320
kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction),
1324-
is(false)
1321+
is(isAlsoCreateIndex)
1322+
);
1323+
assertThat(kibanaRole.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(indexAbstraction), is(isAlsoCreateIndex));
1324+
assertThat(
1325+
kibanaRole.indices().allowedIndicesMatcher(CreateDataStreamAction.NAME).test(indexAbstraction),
1326+
is(isAlsoCreateIndex)
13251327
);
1326-
assertThat(kibanaRole.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(indexAbstraction), is(isAlsoAutoCreateIndex));
1327-
assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateDataStreamAction.NAME).test(indexAbstraction), is(false));
13281328
assertThat(
13291329
kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction),
13301330
is(isAlsoAutoCreateIndex)

0 commit comments

Comments
 (0)