Skip to content

Commit

Permalink
[Security Solution][Detection Engine] adds bulkGetUserProfiles privil…
Browse files Browse the repository at this point in the history
…ege to Security Feature (#211824)

## Summary

- addresses #202051

Few observations, based on ticket
[description](#202051):

1. User can update assignees in alert(i.e. update any alert details,
which is handled by **SecuritySolution** priv)
2. User can see suggested users in searchbox
3. User **can not** see assignees details(name, avatar) in alerts table
column and alerts flyout(that's where error toast originates from)

Why this happens?
2 different APIs used to show users in searchbox and user details in
alerts table column:

1. API to show users in searchbox:
[/internal/detection_engine/users/_find](https://github.com/elastic/kibana/blob/8.18/x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/routes/users/suggest_user_profiles_route.ts#L24)
It requires `securitySolution` privilege
2. API for alerts table cell:
[/internal/security/user_profile/_bulk_get](https://github.com/elastic/kibana/blob/8.18/x-pack/platform/plugins/shared/security/server/routes/user_profile/bulk_get.ts#L20)
It requires `bulkGetUserProfiles` privilege

User was configured with read only Security Feature, that covers only
first API, that's why we see error
> API [POST /internal/security/user_profile/_bulk_get] is unauthorized
for user, this action is granted by the Kibana privileges
[bulkGetUserProfiles] (403)

However `bulkGetUserProfiles` is covered by `Cases` feature already. If
Cases access will be set to read, user would be able to see assignees
details through `/internal/security/user_profile/_bulk_get` API.
It happens, because cases API tags include `bulkGetUserProfiles`
privilege:
https://github.com/elastic/kibana/blob/8.18/x-pack/platform/plugins/shared/cases/common/utils/api_tags.ts#L32,
https://github.com/elastic/kibana/blob/8.18/x-pack/solutions/security/packages/features/src/cases/types.ts#L7

This PR includes `bulkGetUserProfiles` privilege in Security Feature:
#211824. Since, it's already
present in Cases feature, and user profiles available through Security
Solution `/internal/detection_engine/users/_find` API

(cherry picked from commit 847be91)

# Conflicts:
#	x-pack/test_serverless/api_integration/test_suites/security/platform_security/authorization.ts
  • Loading branch information
vitaliidm committed Mar 4, 2025
1 parent 7cd2df8 commit 23c48c5
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const getSecurityBaseKibanaFeature = ({
'timeline_read',
'notes_write',
'notes_read',
'bulkGetUserProfiles',
],
savedObject: {
all: ['alert', ...savedObjects],
Expand Down Expand Up @@ -159,6 +160,7 @@ export const getSecurityBaseKibanaFeature = ({
'cloud-defend-read',
'timeline_read',
'notes_read',
'bulkGetUserProfiles',
],
savedObject: {
all: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const getSecurityV2BaseKibanaFeature = ({
'cloud-security-posture-read',
'cloud-defend-all',
'cloud-defend-read',
'bulkGetUserProfiles',
],
savedObject: {
all: ['alert', ...savedObjects],
Expand All @@ -104,7 +105,14 @@ export const getSecurityV2BaseKibanaFeature = ({
read: {
app: [APP_ID, CLOUD_POSTURE_APP_ID, CLOUD_DEFEND_APP_ID, 'kibana'],
catalogue: [APP_ID],
api: [APP_ID, 'lists-read', 'rac', 'cloud-security-posture-read', 'cloud-defend-read'],
api: [
APP_ID,
'lists-read',
'rac',
'cloud-security-posture-read',
'cloud-defend-read',
'bulkGetUserProfiles',
],
savedObject: {
all: [],
read: [...savedObjects],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import {
casesReadUser,
obsCasesAllUser,
obsCasesReadUser,
secAllCasesNoneUser,
secAllUser,
secReadCasesReadUser,
secAllCasesNoneUser,
secNoneUser,
} from './common/users';

export default ({ getService }: FtrProviderContext): void => {
Expand Down Expand Up @@ -67,6 +68,7 @@ export default ({ getService }: FtrProviderContext): void => {
{ user: secReadCasesReadUser },
{ user: casesReadUser },
{ user: obsCasesReadUser },
{ user: secAllCasesNoneUser },
]) {
it(`User ${
user.username
Expand All @@ -82,7 +84,7 @@ export default ({ getService }: FtrProviderContext): void => {
});
}

for (const { user } of [{ user: secAllCasesNoneUser }]) {
for (const { user } of [{ user: secNoneUser }]) {
it(`User ${
user.username
} with roles(s) ${user.roles.join()} cannot bulk get user profiles because they lack the bulkGetUserProfiles privilege`, async () => {
Expand Down
24 changes: 24 additions & 0 deletions x-pack/test/api_integration/apis/cases/common/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,30 @@ export const secReadCasesNone: Role = {
},
};

export const secNone: Role = {
name: 'sec_none_role_api_int',
privileges: {
elasticsearch: {
indices: [
{
names: ['*'],
privileges: ['all'],
},
],
},
kibana: [
{
feature: {
siem: [],
actions: ['all'],
actionsSimulators: ['all'],
},
spaces: ['*'],
},
],
},
};

/**
* Roles for Cases in the stack
*/
Expand Down
8 changes: 8 additions & 0 deletions x-pack/test/api_integration/apis/cases/common/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
secReadCasesAll,
secReadCasesNone,
secReadCasesRead,
secNone,
casesV2NoReopenWithCreateComment,
obsCasesV2NoReopenWithCreateComment,
secCasesV2NoReopenWithCreateComment,
Expand Down Expand Up @@ -132,6 +133,12 @@ export const secReadUser: User = {
roles: [secRead.name],
};

export const secNoneUser: User = {
username: 'sec_none_user_api_int',
password: 'password',
roles: [secNone.name],
};

export const secReadCasesNoneUser: User = {
username: 'sec_read_cases_none_user_api_int',
password: 'password',
Expand Down Expand Up @@ -297,6 +304,7 @@ export const users = [
secReadCasesAllUser,
secReadCasesReadUser,
secReadUser,
secNoneUser,
secReadCasesNoneUser,
casesOnlyDeleteUser,
casesOnlyReadDeleteUser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export default function ({ getService }: FtrProviderContext) {
"api:cloud-security-posture-read",
"api:cloud-defend-all",
"api:cloud-defend-read",
"api:bulkGetUserProfiles",
"api:securitySolution-entity-analytics",
"api:securitySolution-threat-intelligence",
"api:securitySolution-showEndpointExceptions",
Expand Down Expand Up @@ -838,12 +839,11 @@ export default function ({ getService }: FtrProviderContext) {
"saved_object:search-session/delete",
"saved_object:search-session/bulk_delete",
"saved_object:search-session/share_to_space",
"ui:discover/show",
"ui:discover/save",
"ui:discover/saveQuery",
"ui:discover/createShortUrl",
"ui:discover/storeSearchSession",
"ui:discover/generateCsv",
"ui:discover_v2/show",
"ui:discover_v2/save",
"ui:discover_v2/createShortUrl",
"ui:discover_v2/storeSearchSession",
"ui:discover_v2/generateCsv",
"api:bulkGetUserProfiles",
"api:dashboardUsageStats",
"api:downloadCsv",
Expand Down Expand Up @@ -1079,6 +1079,7 @@ export default function ({ getService }: FtrProviderContext) {
"api:cloud-security-posture-read",
"api:cloud-defend-all",
"api:cloud-defend-read",
"api:bulkGetUserProfiles",
"api:securitySolution-entity-analytics",
"api:securitySolution-threat-intelligence",
"app:securitySolution",
Expand Down Expand Up @@ -1694,12 +1695,11 @@ export default function ({ getService }: FtrProviderContext) {
"saved_object:search-session/delete",
"saved_object:search-session/bulk_delete",
"saved_object:search-session/share_to_space",
"ui:discover/show",
"ui:discover/save",
"ui:discover/saveQuery",
"ui:discover/createShortUrl",
"ui:discover/storeSearchSession",
"ui:discover/generateCsv",
"ui:discover_v2/show",
"ui:discover_v2/save",
"ui:discover_v2/createShortUrl",
"ui:discover_v2/storeSearchSession",
"ui:discover_v2/generateCsv",
"api:bulkGetUserProfiles",
"api:dashboardUsageStats",
"api:downloadCsv",
Expand Down Expand Up @@ -1797,6 +1797,7 @@ export default function ({ getService }: FtrProviderContext) {
"api:rac",
"api:cloud-security-posture-read",
"api:cloud-defend-read",
"api:bulkGetUserProfiles",
"api:securitySolution-entity-analytics",
"api:securitySolution-threat-intelligence",
"app:securitySolution",
Expand Down Expand Up @@ -2070,13 +2071,8 @@ export default function ({ getService }: FtrProviderContext) {
"saved_object:search/find",
"saved_object:search/open_point_in_time",
"saved_object:search/close_point_in_time",
"saved_object:query/bulk_get",
"saved_object:query/get",
"saved_object:query/find",
"saved_object:query/open_point_in_time",
"saved_object:query/close_point_in_time",
"ui:discover/show",
"ui:discover/createShortUrl",
"ui:discover_v2/show",
"ui:discover_v2/createShortUrl",
"api:bulkGetUserProfiles",
"api:dashboardUsageStats",
"app:dashboards",
Expand Down Expand Up @@ -2167,6 +2163,7 @@ export default function ({ getService }: FtrProviderContext) {
"api:rac",
"api:cloud-security-posture-read",
"api:cloud-defend-read",
"api:bulkGetUserProfiles",
"api:securitySolution-entity-analytics",
"api:securitySolution-threat-intelligence",
"api:securitySolution-showEndpointExceptions",
Expand Down Expand Up @@ -2442,13 +2439,8 @@ export default function ({ getService }: FtrProviderContext) {
"saved_object:search/find",
"saved_object:search/open_point_in_time",
"saved_object:search/close_point_in_time",
"saved_object:query/bulk_get",
"saved_object:query/get",
"saved_object:query/find",
"saved_object:query/open_point_in_time",
"saved_object:query/close_point_in_time",
"ui:discover/show",
"ui:discover/createShortUrl",
"ui:discover_v2/show",
"ui:discover_v2/createShortUrl",
"api:bulkGetUserProfiles",
"api:dashboardUsageStats",
"app:dashboards",
Expand Down

0 comments on commit 23c48c5

Please sign in to comment.