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] Allow only users with 'all' privileges to install and upgrade prebuilt rules #161454

Merged

Conversation

jpdjere
Copy link
Contributor

@jpdjere jpdjere commented Jul 7, 2023

Fixes: #161443

Summary

When user doesn't have write permission:

  • Disables "Add Elastic rules" button and removes Rule Updates tab
    image

  • Disables buttons to individually install rules, install selected rules and install all rules
    image

  • Disables buttons to individually upgrade rules, upgrade selected rules and upgrade all rules
    image

_perform endpoints

  • Returns 403 when installing all rules or specific rules
    image
    image

  • Returns 403 when upgrading all rules or specific rules
    image
    image

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@jpdjere jpdjere self-assigned this Jul 7, 2023
@jpdjere jpdjere added 8.9 candidate 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 v8.9.0 v8.10.0 labels Jul 7, 2023
@jpdjere jpdjere force-pushed the write-access-perform-install-update-endpoints branch from cf4398f to 263282a Compare July 7, 2023 13:33
@jpdjere jpdjere marked this pull request as ready for review July 7, 2023 14:37
@jpdjere jpdjere requested a review from a team as a code owner July 7, 2023 14:37
@jpdjere jpdjere requested a review from maximpn July 7, 2023 14:37
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@jpdjere jpdjere requested review from banderror and removed request for maximpn July 7, 2023 14:37
@jpdjere jpdjere added the release_note:skip Skip the PR/issue when compiling release notes label Jul 7, 2023
@xcrzx
Copy link
Contributor

xcrzx commented Jul 10, 2023

We also need to disable install buttons on the Add Rules screen:

image

@xcrzx
Copy link
Contributor

xcrzx commented Jul 10, 2023

We also need to disable the upgrade buttons on the Update Rules screen:

image

@xcrzx xcrzx force-pushed the write-access-perform-install-update-endpoints branch from e1a401b to f2006a1 Compare July 10, 2023 11:27
Copy link
Contributor

@xcrzx xcrzx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed two more cases in this PR where we needed to disable the upgrade and install rules buttons. It seems like all possible user interactions are now covered.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 11.1MB 11.1MB +251.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
securitySolution 408 412 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
securitySolution 487 491 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jpdjere

@banderror banderror merged commit 31b28a0 into elastic:main Jul 10, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request 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
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.9

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request 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>
xcrzx added a commit that referenced this pull request 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 pull request 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)
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 impact:critical This issue should be addressed immediately due to a critical level of impact on the product. release_note:skip Skip the PR/issue when compiling release notes 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 v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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