Skip to content

Commit b77fc67

Browse files
authored
Add permissions to kibana_system for TI package transforms to support IOC expiration (#94506)
* Add permissions to kibana_system for TI package transforms to support IOC expiration * Update perm; add tests and changelog * Apply checks * update test * Add perm for ILM policy on source * Address PR comment * Update test comments * retrigger * Update patterns and add comments * Remove dot prefix
1 parent cf28403 commit b77fc67

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

docs/changelog/94506.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 94506
2+
summary: Add permissions to kibana_system for TI package transforms to support IOC expiration
3+
area: Authorization
4+
type: enhancement
5+
issues:
6+
- 94505

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,32 @@ public static RoleDescriptor kibanaSystemRoleDescriptor(String name) {
864864
)
865865
.privileges("create_index", "delete_index", "read", "index", IndicesAliasesAction.NAME, UpdateSettingsAction.NAME)
866866
.build(),
867+
// For destination indices of the Threat Intel (ti_*) packages that ships a transform for supporting IOC expiration
868+
RoleDescriptor.IndicesPrivileges.builder()
869+
.indices("logs-ti_*_latest.*")
870+
.privileges(
871+
// Require "create_index", "delete_index", "read", "index", "delete", IndicesAliasesAction.NAME, and
872+
// UpdateSettingsAction.NAME for transform
873+
"create_index",
874+
"delete_index",
875+
"read",
876+
"index",
877+
"delete",
878+
IndicesAliasesAction.NAME,
879+
UpdateSettingsAction.NAME
880+
)
881+
.build(),
882+
// For source indices of the Threat Intel (ti_*) packages that ships a transform for supporting IOC expiration
883+
RoleDescriptor.IndicesPrivileges.builder()
884+
.indices("logs-ti_*.*-*")
885+
.privileges(
886+
// Require "delete_index" to perform ILM policy actions
887+
DeleteIndexAction.NAME,
888+
// Require "read" and "view_index_metadata" for transform
889+
"read",
890+
"view_index_metadata"
891+
)
892+
.build(),
867893
// For src/dest indices of the example transform package
868894
RoleDescriptor.IndicesPrivileges.builder()
869895
.indices("kibana_sample_data_*")

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,65 @@ public void testKibanaSystemRole() {
10471047
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(false));
10481048
});
10491049

1050+
// Test allow permissions on Threat Intel (ti*) dest indices created by latest transform : "create_index", "delete_index", "read",
1051+
// "index", "delete", IndicesAliasesAction.NAME, UpdateSettingsAction.NAME
1052+
Arrays.asList("logs-ti_recordedfuture_latest.threat", "logs-ti_anomali_latest.threatstream").forEach(indexName -> {
1053+
final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName);
1054+
// Allow search and indexing
1055+
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(indexAbstraction), is(true));
1056+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true));
1057+
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(true));
1058+
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateAction.NAME).test(indexAbstraction), is(true));
1059+
assertThat(kibanaRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(indexAbstraction), is(true));
1060+
// Allow create and delete index, modifying aliases, and updating index settings
1061+
assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(true));
1062+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true));
1063+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAliasesAction.NAME).test(indexAbstraction), is(true));
1064+
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndicesAliasesAction.NAME).test(indexAbstraction), is(true));
1065+
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true));
1066+
1067+
// Allow deleting documents
1068+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(true));
1069+
1070+
// Implied by the overall view_index_metadata and monitor privilege
1071+
assertViewIndexMetadata(kibanaRole, indexName);
1072+
assertThat(
1073+
kibanaRole.indices().allowedIndicesMatcher("indices:monitor/" + randomAlphaOfLengthBetween(3, 8)).test(indexAbstraction),
1074+
is(true)
1075+
);
1076+
});
1077+
1078+
// Test allow permissions on Threat Intel (ti*) source indices required by latest transform : "read", "view_index_metadata",
1079+
// IndicesAliasesAction.NAME, PutMappingAction.NAME, UpdateSettingsAction.NAME, "delete_index"
1080+
Arrays.asList(
1081+
"logs-ti_recordedfuture.threat-default",
1082+
"logs-ti_anomali.threatstream-default",
1083+
"logs-ti_recordedfuture.threat-default" + randomAlphaOfLength(randomIntBetween(0, 13)),
1084+
"logs-ti_anomali.threatstream-default" + randomAlphaOfLength(randomIntBetween(0, 13))
1085+
).forEach(indexName -> {
1086+
final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName);
1087+
// Allow read-only
1088+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false));
1089+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false));
1090+
assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false));
1091+
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false));
1092+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false));
1093+
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true));
1094+
assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true));
1095+
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
1096+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true));
1097+
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(indexAbstraction), is(true));
1098+
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(indexAbstraction), is(true));
1099+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true));
1100+
1101+
// Implied by the overall view_index_metadata and monitor privilege
1102+
assertViewIndexMetadata(kibanaRole, indexName);
1103+
assertThat(
1104+
kibanaRole.indices().allowedIndicesMatcher("indices:monitor/" + randomAlphaOfLengthBetween(3, 8)).test(indexAbstraction),
1105+
is(true)
1106+
);
1107+
});
1108+
10501109
Arrays.asList(
10511110
".logs-osquery_manager.actions-" + randomAlphaOfLength(randomIntBetween(0, 13)),
10521111
".logs-osquery_manager.action.responses-" + randomAlphaOfLength(randomIntBetween(0, 13))

0 commit comments

Comments
 (0)