Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] User with Security: Read privileges can install and upgrade prebuilt rules via UI #161443

Closed
Tracked by #174167
banderror opened this issue Jul 7, 2023 · 5 comments · Fixed by #161454
Assignees
Labels
8.9 candidate blocker bug Fixes for quality problems that affect the customer experience Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area fixed impact:critical This issue should be addressed immediately due to a critical level of impact on the product. QA:Validated Issue has been validated by QA Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.9.0

Comments

@banderror
Copy link
Contributor

banderror commented Jul 7, 2023

🚨🚨🚨 This is a blocker for the 8.9.0 release 🚨🚨🚨

Summary

A user who has Security: Read privileges + other privileges required for Detections (docs) is able to install and upgrade prebuilt rules from the UI.

Expected behavior:

  • User should not be able to do it at least from the UI (we can add privilege checks in UI and API in two different PRs, it'd be more important to hot-fix this in the UI at this point).
  • All the [Install*] and [Update*] buttons should be disabled.
  • The Add Elastic rules button should be disabled (both the 2 buttons, actually).
  • The Rule Updates tab should be disabled.
  • A tooltip should be added to each disabled element with an explanation of why it is disabled.

Screenshots

User role

Screenshot 2023-07-07 at 12 38 47

Rule installation

Screenshot 2023-07-07 at 12 39 42 Screenshot 2023-07-07 at 12 40 20

Rule upgrade

Screenshot 2023-07-07 at 12 44 15
@banderror banderror added bug Fixes for quality problems that affect the customer experience blocker impact:critical This issue should be addressed immediately due to a critical level of impact on the product. Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area 8.9 candidate v8.9.0 labels Jul 7, 2023
banderror pushed a commit that referenced this issue Jul 10, 2023
… and upgrade prebuilt rules (#161454)

Fixes: #161443

## Summary

### When user doesn't have write permission:
- Disables "Add Elastic rules" button and removes Rule Updates tab

![image](https://github.com/elastic/kibana/assets/5354282/a173f18f-9b6b-4c9a-bf5f-207af13e24cb)

- Disables buttons to individually install rules, install selected rules
and install all rules

![image](https://github.com/elastic/kibana/assets/5354282/4d24d440-17f4-4d1d-96fc-4eb07914cff0)

- Disables buttons to individually upgrade rules, upgrade selected rules
and upgrade all rules

![image](https://github.com/elastic/kibana/assets/5354282/036236c1-dac0-42b8-87e5-0244d9ead281)

### `_perform` endpoints
- Returns 403 when installing all rules or specific rules

![image](https://github.com/elastic/kibana/assets/5354282/adc20409-ff09-42e5-aa33-0f1ec0df46f6)

![image](https://github.com/elastic/kibana/assets/5354282/d1faf778-d857-458e-afeb-7c573e7bf4d3)

- Returns 403 when upgrading all rules or specific rules

![image](https://github.com/elastic/kibana/assets/5354282/b21ffaa7-416c-402a-a157-12735f28e689)

![image](https://github.com/elastic/kibana/assets/5354282/b8dfecc6-4cfe-462c-9e9c-6344f59aa2d5)


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Dmitrii <dmitrii.shevchenko@elastic.co>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Jul 10, 2023
… and upgrade prebuilt rules (elastic#161454)

Fixes: elastic#161443

## Summary

### When user doesn't have write permission:
- Disables "Add Elastic rules" button and removes Rule Updates tab

![image](https://github.com/elastic/kibana/assets/5354282/a173f18f-9b6b-4c9a-bf5f-207af13e24cb)

- Disables buttons to individually install rules, install selected rules
and install all rules

![image](https://github.com/elastic/kibana/assets/5354282/4d24d440-17f4-4d1d-96fc-4eb07914cff0)

- Disables buttons to individually upgrade rules, upgrade selected rules
and upgrade all rules

![image](https://github.com/elastic/kibana/assets/5354282/036236c1-dac0-42b8-87e5-0244d9ead281)

### `_perform` endpoints
- Returns 403 when installing all rules or specific rules

![image](https://github.com/elastic/kibana/assets/5354282/adc20409-ff09-42e5-aa33-0f1ec0df46f6)

![image](https://github.com/elastic/kibana/assets/5354282/d1faf778-d857-458e-afeb-7c573e7bf4d3)

- Returns 403 when upgrading all rules or specific rules

![image](https://github.com/elastic/kibana/assets/5354282/b21ffaa7-416c-402a-a157-12735f28e689)

![image](https://github.com/elastic/kibana/assets/5354282/b8dfecc6-4cfe-462c-9e9c-6344f59aa2d5)

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Dmitrii <dmitrii.shevchenko@elastic.co>
(cherry picked from commit 31b28a0)
kibanamachine referenced this issue Jul 10, 2023
…nstall and upgrade prebuilt rules (#161454) (#161555)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Security Solution] Allow only users with 'all' privileges to install
and upgrade prebuilt rules
(#161454)](#161454)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Juan Pablo
Djeredjian","email":"jpdjeredjian@gmail.com"},"sourceCommit":{"committedDate":"2023-07-10T14:35:17Z","message":"[Security
Solution] Allow only users with 'all' privileges to install and upgrade
prebuilt rules (#161454)\n\nFixes:
https://github.com/elastic/kibana/issues/161443\r\n\r\n##
Summary\r\n\r\n### When user doesn't have write permission:\r\n-
Disables \"Add Elastic rules\" button and removes Rule Updates
tab\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/a173f18f-9b6b-4c9a-bf5f-207af13e24cb)\r\n\r\n-
Disables buttons to individually install rules, install selected
rules\r\nand install all
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/4d24d440-17f4-4d1d-96fc-4eb07914cff0)\r\n\r\n-
Disables buttons to individually upgrade rules, upgrade selected
rules\r\nand upgrade all
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/036236c1-dac0-42b8-87e5-0244d9ead281)\r\n\r\n###
`_perform` endpoints\r\n- Returns 403 when installing all rules or
specific
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/adc20409-ff09-42e5-aa33-0f1ec0df46f6)\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/d1faf778-d857-458e-afeb-7c573e7bf4d3)\r\n\r\n-
Returns 403 when upgrading all rules or specific
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/b21ffaa7-416c-402a-a157-12735f28e689)\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/b8dfecc6-4cfe-462c-9e9c-6344f59aa2d5)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any UI touched in this PR is usable by keyboard only
(learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Dmitrii
<dmitrii.shevchenko@elastic.co>","sha":"31b28a06606d4f5b1fe10173859c44fb9fce3b10","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","blocker","release_note:skip","impact:critical","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","Feature:Prebuilt Detection Rules","8.9
candidate","v8.9.0","v8.10.0"],"number":161454,"url":"https://github.com/elastic/kibana/pull/161454","mergeCommit":{"message":"[Security
Solution] Allow only users with 'all' privileges to install and upgrade
prebuilt rules (#161454)\n\nFixes:
https://github.com/elastic/kibana/issues/161443\r\n\r\n##
Summary\r\n\r\n### When user doesn't have write permission:\r\n-
Disables \"Add Elastic rules\" button and removes Rule Updates
tab\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/a173f18f-9b6b-4c9a-bf5f-207af13e24cb)\r\n\r\n-
Disables buttons to individually install rules, install selected
rules\r\nand install all
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/4d24d440-17f4-4d1d-96fc-4eb07914cff0)\r\n\r\n-
Disables buttons to individually upgrade rules, upgrade selected
rules\r\nand upgrade all
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/036236c1-dac0-42b8-87e5-0244d9ead281)\r\n\r\n###
`_perform` endpoints\r\n- Returns 403 when installing all rules or
specific
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/adc20409-ff09-42e5-aa33-0f1ec0df46f6)\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/d1faf778-d857-458e-afeb-7c573e7bf4d3)\r\n\r\n-
Returns 403 when upgrading all rules or specific
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/b21ffaa7-416c-402a-a157-12735f28e689)\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/b8dfecc6-4cfe-462c-9e9c-6344f59aa2d5)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any UI touched in this PR is usable by keyboard only
(learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Dmitrii
<dmitrii.shevchenko@elastic.co>","sha":"31b28a06606d4f5b1fe10173859c44fb9fce3b10"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/161454","number":161454,"mergeCommit":{"message":"[Security
Solution] Allow only users with 'all' privileges to install and upgrade
prebuilt rules (#161454)\n\nFixes:
https://github.com/elastic/kibana/issues/161443\r\n\r\n##
Summary\r\n\r\n### When user doesn't have write permission:\r\n-
Disables \"Add Elastic rules\" button and removes Rule Updates
tab\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/a173f18f-9b6b-4c9a-bf5f-207af13e24cb)\r\n\r\n-
Disables buttons to individually install rules, install selected
rules\r\nand install all
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/4d24d440-17f4-4d1d-96fc-4eb07914cff0)\r\n\r\n-
Disables buttons to individually upgrade rules, upgrade selected
rules\r\nand upgrade all
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/036236c1-dac0-42b8-87e5-0244d9ead281)\r\n\r\n###
`_perform` endpoints\r\n- Returns 403 when installing all rules or
specific
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/adc20409-ff09-42e5-aa33-0f1ec0df46f6)\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/d1faf778-d857-458e-afeb-7c573e7bf4d3)\r\n\r\n-
Returns 403 when upgrading all rules or specific
rules\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/b21ffaa7-416c-402a-a157-12735f28e689)\r\n\r\n![image](https://github.com/elastic/kibana/assets/5354282/b8dfecc6-4cfe-462c-9e9c-6344f59aa2d5)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any UI touched in this PR is usable by keyboard only
(learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
For maintainers\r\n\r\n- [ ] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Dmitrii
<dmitrii.shevchenko@elastic.co>","sha":"31b28a06606d4f5b1fe10173859c44fb9fce3b10"}}]}]
BACKPORT-->

Co-authored-by: Juan Pablo Djeredjian <jpdjeredjian@gmail.com>
@banderror banderror reopened this Jul 10, 2023
@xcrzx
Copy link
Contributor

xcrzx commented Jul 11, 2023

Privilege checks on the API level have been removed as they prevent a properly configured role from installing or updating detection rules. See #161641

xcrzx added a commit that referenced this issue Jul 11, 2023
…d update (#161641)

**Related to: #161443,
#161454

## Summary

The `access:securitySolution-all` access level prevents a properly
configured role from installing or updating detection rules. This PR
aligns the access level for the `installation/_perform` and
`upgrade/_perform` endpoints with the rest of the detection engine APIs.

### Test instructions

Configure a role with the following permissions:

```json
{
  "test": {
    "cluster": [],
    "indices": [
      {
        "names": [
          ".alerts-security.alerts-default",
          ".lists-default",
          ".items-default"
        ],
        "privileges": [
          "read",
          "write",
          "view_index_metadata",
          "maintenance"
        ],
        "field_security": {
          "grant": [
            "*"
          ]
        },
        "allow_restricted_indices": false
      }
    ],
    "applications": [
      {
        "application": "kibana-.kibana",
        "privileges": [
          "feature_siem.all"
        ],
        "resources": [
          "*"
        ]
      }
    ],
    "run_as": [],
    "metadata": {},
    "transient_metadata": {
      "enabled": true
    }
  }
}
```

Call the upgrade/install APIs on behalf of that role to see that no 403
is returned:

```sh
curl --location 'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/installation/_perform' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
    "mode": "ALL_RULES"
}'

curl --location 'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/upgrade/_perform' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
    "mode": "ALL_RULES"
}'
```
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Jul 11, 2023
…d update (elastic#161641)

**Related to: elastic#161443,
elastic#161454

## Summary

The `access:securitySolution-all` access level prevents a properly
configured role from installing or updating detection rules. This PR
aligns the access level for the `installation/_perform` and
`upgrade/_perform` endpoints with the rest of the detection engine APIs.

### Test instructions

Configure a role with the following permissions:

```json
{
  "test": {
    "cluster": [],
    "indices": [
      {
        "names": [
          ".alerts-security.alerts-default",
          ".lists-default",
          ".items-default"
        ],
        "privileges": [
          "read",
          "write",
          "view_index_metadata",
          "maintenance"
        ],
        "field_security": {
          "grant": [
            "*"
          ]
        },
        "allow_restricted_indices": false
      }
    ],
    "applications": [
      {
        "application": "kibana-.kibana",
        "privileges": [
          "feature_siem.all"
        ],
        "resources": [
          "*"
        ]
      }
    ],
    "run_as": [],
    "metadata": {},
    "transient_metadata": {
      "enabled": true
    }
  }
}
```

Call the upgrade/install APIs on behalf of that role to see that no 403
is returned:

```sh
curl --location 'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/installation/_perform' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
    "mode": "ALL_RULES"
}'

curl --location 'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/upgrade/_perform' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
    "mode": "ALL_RULES"
}'
```

(cherry picked from commit a5627be)
kibanamachine referenced this issue Jul 11, 2023
…ion and update (#161641) (#161649)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Security Solution] Fix endpoint permissions for rule installation
and update (#161641)](#161641)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dmitrii
Shevchenko","email":"dmitrii.shevchenko@elastic.co"},"sourceCommit":{"committedDate":"2023-07-11T13:07:35Z","message":"[Security
Solution] Fix endpoint permissions for rule installation and update
(#161641)\n\n**Related to:
https://github.com/elastic/kibana/issues/161443,\r\nhttps://github.com/elastic/kibana/pull/161454**\r\n\r\n##
Summary\r\n\r\nThe `access:securitySolution-all` access level prevents a
properly\r\nconfigured role from installing or updating detection rules.
This PR\r\naligns the access level for the `installation/_perform`
and\r\n`upgrade/_perform` endpoints with the rest of the detection
engine APIs.\r\n\r\n### Test instructions\r\n\r\nConfigure a role with
the following permissions:\r\n\r\n```json\r\n{\r\n \"test\": {\r\n
\"cluster\": [],\r\n \"indices\": [\r\n {\r\n \"names\": [\r\n
\".alerts-security.alerts-default\",\r\n \".lists-default\",\r\n
\".items-default\"\r\n ],\r\n \"privileges\": [\r\n \"read\",\r\n
\"write\",\r\n \"view_index_metadata\",\r\n \"maintenance\"\r\n ],\r\n
\"field_security\": {\r\n \"grant\": [\r\n \"*\"\r\n ]\r\n },\r\n
\"allow_restricted_indices\": false\r\n }\r\n ],\r\n \"applications\":
[\r\n {\r\n \"application\": \"kibana-.kibana\",\r\n \"privileges\":
[\r\n \"feature_siem.all\"\r\n ],\r\n \"resources\": [\r\n \"*\"\r\n
]\r\n }\r\n ],\r\n \"run_as\": [],\r\n \"metadata\": {},\r\n
\"transient_metadata\": {\r\n \"enabled\": true\r\n }\r\n
}\r\n}\r\n```\r\n\r\nCall the upgrade/install APIs on behalf of that
role to see that no 403\r\nis returned:\r\n\r\n```sh\r\ncurl --location
'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/installation/_perform'
\\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept:
application/json' \\\r\n--data '{\r\n \"mode\":
\"ALL_RULES\"\r\n}'\r\n\r\ncurl --location
'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/upgrade/_perform'
\\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept:
application/json' \\\r\n--data '{\r\n \"mode\":
\"ALL_RULES\"\r\n}'\r\n```","sha":"a5627bec5781575c02dec671f2635eaab8bc4f40","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","blocker","release_note:skip","impact:critical","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","Feature:Prebuilt Detection
Rules","v8.9.0","v8.10.0"],"number":161641,"url":"https://github.com/elastic/kibana/pull/161641","mergeCommit":{"message":"[Security
Solution] Fix endpoint permissions for rule installation and update
(#161641)\n\n**Related to:
https://github.com/elastic/kibana/issues/161443,\r\nhttps://github.com/elastic/kibana/pull/161454**\r\n\r\n##
Summary\r\n\r\nThe `access:securitySolution-all` access level prevents a
properly\r\nconfigured role from installing or updating detection rules.
This PR\r\naligns the access level for the `installation/_perform`
and\r\n`upgrade/_perform` endpoints with the rest of the detection
engine APIs.\r\n\r\n### Test instructions\r\n\r\nConfigure a role with
the following permissions:\r\n\r\n```json\r\n{\r\n \"test\": {\r\n
\"cluster\": [],\r\n \"indices\": [\r\n {\r\n \"names\": [\r\n
\".alerts-security.alerts-default\",\r\n \".lists-default\",\r\n
\".items-default\"\r\n ],\r\n \"privileges\": [\r\n \"read\",\r\n
\"write\",\r\n \"view_index_metadata\",\r\n \"maintenance\"\r\n ],\r\n
\"field_security\": {\r\n \"grant\": [\r\n \"*\"\r\n ]\r\n },\r\n
\"allow_restricted_indices\": false\r\n }\r\n ],\r\n \"applications\":
[\r\n {\r\n \"application\": \"kibana-.kibana\",\r\n \"privileges\":
[\r\n \"feature_siem.all\"\r\n ],\r\n \"resources\": [\r\n \"*\"\r\n
]\r\n }\r\n ],\r\n \"run_as\": [],\r\n \"metadata\": {},\r\n
\"transient_metadata\": {\r\n \"enabled\": true\r\n }\r\n
}\r\n}\r\n```\r\n\r\nCall the upgrade/install APIs on behalf of that
role to see that no 403\r\nis returned:\r\n\r\n```sh\r\ncurl --location
'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/installation/_perform'
\\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept:
application/json' \\\r\n--data '{\r\n \"mode\":
\"ALL_RULES\"\r\n}'\r\n\r\ncurl --location
'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/upgrade/_perform'
\\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept:
application/json' \\\r\n--data '{\r\n \"mode\":
\"ALL_RULES\"\r\n}'\r\n```","sha":"a5627bec5781575c02dec671f2635eaab8bc4f40"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/161641","number":161641,"mergeCommit":{"message":"[Security
Solution] Fix endpoint permissions for rule installation and update
(#161641)\n\n**Related to:
https://github.com/elastic/kibana/issues/161443,\r\nhttps://github.com/elastic/kibana/pull/161454**\r\n\r\n##
Summary\r\n\r\nThe `access:securitySolution-all` access level prevents a
properly\r\nconfigured role from installing or updating detection rules.
This PR\r\naligns the access level for the `installation/_perform`
and\r\n`upgrade/_perform` endpoints with the rest of the detection
engine APIs.\r\n\r\n### Test instructions\r\n\r\nConfigure a role with
the following permissions:\r\n\r\n```json\r\n{\r\n \"test\": {\r\n
\"cluster\": [],\r\n \"indices\": [\r\n {\r\n \"names\": [\r\n
\".alerts-security.alerts-default\",\r\n \".lists-default\",\r\n
\".items-default\"\r\n ],\r\n \"privileges\": [\r\n \"read\",\r\n
\"write\",\r\n \"view_index_metadata\",\r\n \"maintenance\"\r\n ],\r\n
\"field_security\": {\r\n \"grant\": [\r\n \"*\"\r\n ]\r\n },\r\n
\"allow_restricted_indices\": false\r\n }\r\n ],\r\n \"applications\":
[\r\n {\r\n \"application\": \"kibana-.kibana\",\r\n \"privileges\":
[\r\n \"feature_siem.all\"\r\n ],\r\n \"resources\": [\r\n \"*\"\r\n
]\r\n }\r\n ],\r\n \"run_as\": [],\r\n \"metadata\": {},\r\n
\"transient_metadata\": {\r\n \"enabled\": true\r\n }\r\n
}\r\n}\r\n```\r\n\r\nCall the upgrade/install APIs on behalf of that
role to see that no 403\r\nis returned:\r\n\r\n```sh\r\ncurl --location
'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/installation/_perform'
\\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept:
application/json' \\\r\n--data '{\r\n \"mode\":
\"ALL_RULES\"\r\n}'\r\n\r\ncurl --location
'http://localhost:5601/kbn/internal/detection_engine/prebuilt_rules/upgrade/_perform'
\\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept:
application/json' \\\r\n--data '{\r\n \"mode\":
\"ALL_RULES\"\r\n}'\r\n```","sha":"a5627bec5781575c02dec671f2635eaab8bc4f40"}}]}]
BACKPORT-->

Co-authored-by: Dmitrii Shevchenko <dmitrii.shevchenko@elastic.co>
@xcrzx
Copy link
Contributor

xcrzx commented Jul 12, 2023

@banderror Since it turned out that users with read-only privileges couldn't install or upgrade prebuilt detection rules, it seems appropriate to downgrade the severity of this issue from a critical release blocker. Though an enabled install button in the UI leading to a 403 error upon clicking is not ideal for UX, but it is still pretty minor.

@banderror
Copy link
Contributor Author

banderror commented Jul 12, 2023

@xcrzx This role allows a Security readonly user to bypass all the checks and successfully install or upgrade prebuilt rules via the API:

{
  "_test": {
    "cluster": [],
    "indices": [
      {
        "names": [
          "filebeat-*",
          "logs-*",
          "metrics-*",
          "packetbeat-*"
        ],
        "privileges": [
          "read",
          "view_index_metadata"
        ],
        "field_security": {
          "grant": [
            "*"
          ],
          "except": []
        },
        "allow_restricted_indices": false
      }
    ],
    "applications": [
      {
        "application": "kibana-.kibana",
        "privileges": [
          "feature_siem.read",
          "feature_savedObjectsManagement.all"
        ],
        "resources": [
          "*"
        ]
      }
    ],
    "run_as": [],
    "metadata": {},
    "transient_metadata": {
      "enabled": true
    }
  }
}

We should prioritize fixing it in 8.10 for these two endpoints, as well as add appropriate RBAC checks to our other endpoints like CRUD and bulk actions. I'll create a separate ticket for that (https://github.com/elastic/security-team/issues/7114).

Let's keep this ticket with the current labels and close it when QA have verified the fix for the UI.

@banderror banderror changed the title [Security Solution] User with Security: Read privileges can install and upgrade prebuilt rules [Security Solution] User with Security: Read privileges can install and upgrade prebuilt rules via UI Jul 12, 2023
@jpdjere
Copy link
Contributor

jpdjere commented Jul 12, 2023

@banderror

After syncing with @xcrzx, I retried the POST /internal/detection_engine/prebuilt_rules/installation/_perform with a user with the configuration pasted above:

{
  "test-g": {
    "cluster": [],
    "indices": [
      {
        "names": [
          "filebeat-*",
          "logs-*",
          "metrics-*",
          "packetbeat-*"
        ],
        "privileges": [
          "read",
          "view_index_metadata"
        ],
        "field_security": {
          "grant": [
            "*"
          ],
          "except": []
        },
        "allow_restricted_indices": false
      }
    ],
    "applications": [
      {
        "application": "kibana-.kibana",
        "privileges": [
          "feature_siem.read",
          "feature_savedObjectsManagement.all"
        ],
        "resources": [
          "*"
        ]
      }
    ],
    "run_as": [],
    "metadata": {},
    "transient_metadata": {
      "enabled": true
    }
  }
}

And got the expected result:

{
    "summary": {
        "total": 3,
        "succeeded": 0,
        "skipped": 0,
        "failed": 3
    },
    "results": {
        "created": [],
        "skipped": []
    },
    "errors": [
        {
            "message": "Unauthorized to create a \"siem.mlRule\" rule for \"siem\"",
            "rules": [
                {
                    "rule_id": "1781d055-5c66-4adf-9d82-fc0fa58449c8",
                    "name": "Unusual Windows User Privilege Elevation Activity"
                }
            ]
        },
        {
            "message": "Unauthorized to create a \"siem.eqlRule\" rule for \"siem\"",
            "rules": [
                {
                    "rule_id": "15dacaa0-5b90-466b-acab-63435a59701a",
                    "name": "Virtual Private Network Connection Attempt"
                }
            ]
        },
        {
            "message": "Unauthorized to create a \"siem.queryRule\" rule for \"siem\"",
            "rules": [
                {
                    "rule_id": "9a1a2dae-0b5f-4c3d-8305-a268d404c306",
                    "name": "Endpoint Security"
                }
            ]
        }
    ]
}

I get the same type of unauthorized result for upgrading rules.

I think we might have mixed up the users or roles we were using when we tried while syncing this morning. The behaviour is as expected: a user with a role with feature_siem.read cannot install or upgrade rules, even with feature_savedObjectsManagement.all.

That given the case, I think this is enough to close this ticket and https://github.com/elastic/security-team/issues/7114

One upgrade that can be done here, as we discussed with @xcrzx, is that the validation for privilege is done at the Rules Client level, which means that the check is done for every rule that is attempted to be installed or updated. We can move that check to our endpoint handler level to have a cleaner check and improve performance. I created this tech debt ticket for that: #161772

@vgomez-el vgomez-el added the QA:Validated Issue has been validated by QA label Jul 24, 2023
@vgomez-el
Copy link

Fix for the UI has been verified, so I will close the issue and label it as validated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.9 candidate blocker bug Fixes for quality problems that affect the customer experience Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area fixed impact:critical This issue should be addressed immediately due to a critical level of impact on the product. QA:Validated Issue has been validated by QA Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.9.0
Projects
None yet
4 participants