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

[SecuritySolution][Detections] Fix "Closing a signal silently fails with reduced privileges" #86908

Merged
merged 5 commits into from
Jan 5, 2021

Conversation

banderror
Copy link
Contributor

@banderror banderror commented Dec 23, 2020

Addresses: #56991

Summary

This PR introduces the following changes. If the user has insufficient write privileges on the signals index:

  • we disable the status-changing actions on detection alerts ("Open alert", "Close Alert", "Mark in progress") in the context menu of an alert in alerts table
  • we make sure to show the corresponding callout that tells about read-only access to detection alerts
  • in the callout we provide links to docs for understanding why/how to fix

This is based on @spong's suggestion in the GH issue.

TODO:

  • Add a new hasIndexUpdateDelete flag indicating true (full) write privilege on the signals index.
  • Update ReadOnlyAlertsCallOut component to use hasIndexUpdateDelete instead of hasIndexWrite. This makes sure we show the callout.
  • Update AlertContextMenu component to use hasIndexUpdateDelete. This makes sure we disable the context menu actions.
  • Add links to docs to our read-only callouts: ReadOnlyAlertsCallOut and ReadOnlyRulesCallOut.

Screenshots

This is how it looks like for our readonly user role (the one that has "Read" on Kibana Security as well) - we show both callouts with the links (definitely not ideal, and this is another reason for improving/standardising callouts UI across the solution):

Details

Useful links

Some docs:

Some related PRs:

  • Xavier's change where he changes the implementation of hasIndexWrite
  • Devin's comment on a very related case where the user clicks "Open alert", "Close Alert", "Mark in progress" and gets an error which is related to insufficient privileges (this is a different bug)

hasIndexWrite

This was an interesting one for me to play around and figure out how index privileges are implemented in Elasticsearch and in our security_solution codebase.

Docs for index privileges do not explicitly show how all of them are related to each other. Probably it's not a secret for many devs, but I had to experiment with assigning each privilege and checking which other privileges the user gets automatically:

POST /_security/user/_has_privileges
{
  "cluster": [
    "all"
  ],
  "index": [
    {
      "names": [".siem-signals*"],
      "privileges": [
        "all",
        "auto_configure",
        "create",
        "create_doc",
        "create_index",
        "delete",
        "delete_index",
        "index",
        "maintenance",
        "manage",
        "manage_follow_index",
        "manage_ilm",
        "manage_leader_index",
        "monitor",
        "read",
        "read_cross_cluster",
        "view_index_metadata",
        "write"
      ]
    }
  ]
}

E.g. I was assigning index, running this ES query and checking the result. If only index is granted, the user gets index, create and create_doc automatically. This is Elasticsearch behavoiur.

This way I figured out dependencies between all the index privileges (sorry for quality, looks like a kid's drawing):

IMAGE 2020-12-23 20:30:32

What does this mean for us? If I'm not mistaken, this doesn't have to combine all of the privileges with OR:

hasIndexWrite:
  privilege.index[indexName].create ||
  privilege.index[indexName].create_doc ||
  privilege.index[indexName].index ||
  privilege.index[indexName].write,

because it folds to just privilege.index[indexName].create_doc, because write grants all of them automatically. And because of that hasIndexWrite actually makes sure that the user has create_doc 100%, but not necessarily create or index or write.

So perhaps it's a good idea to rename hasIndexWrite to hasIndexCreateDoc, because true hasIndexWrite (full write permissions guaranteeing updates and deletions) would be implemented like that:

hasIndexWrite: privilege.index[indexName].write,

I found a similar OR logic in lists plugin as well.

I18n

You can notice that callout messages are localized, but links to documentation are not. I did it on purpose to keep it simple and because I'm not sure they have to be localizable. The reason is - I'm not even sure we have docs for security solution in other languages. For me it seems like docs in other languages are outdated. Pls correct me if I'm wrong.

To do later?

I tried to keep this PR as thin as possible so it could be merged to 7.11 after feature freeze 🙂
But there are things that I was either considering doing right away (and then decided to postpone) or just thinking about.

  • Some refactoring of the privileges-related code. I think it's a good idea to expose detailed privileges on every index and Kibana UI capabilities which is relevant to Security. Make it available across the app (common code) as SecuritySolutionUserPrivileges. Maybe create derived DetectionsUserPrivileges in detections like canUserUpdateAlerts. At least rename hasIndexWrite -> hasIndexCreateDoc and hasIndexUpdateDelete -> hasIndexWrite for consistency with Elasticsearch terminology.
  • Add tooltips to disabled alert context menu items like in Devin's PR for rule actions.
  • Should we better communicate the user about insufficient privileges to .lists* and .items*? Currently if the user doesn't have access to lists, we show an error message (toast) which you can see on the screenshots and in the issue. Should we create an error callout for that?
  • Make a proper diagram showing dependencies between privileges and contribute to Elasticsearch docs.

I think there's some room for improvement here in how we implement RBAC in the UI: handle errors, communicate to the user what's possible and what's not, how we display it.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@banderror banderror self-assigned this Dec 23, 2020
@banderror banderror added Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detections and Resp Security Detection Response Team Feature:Detection Rules Security Solution rules and Detection Engine Feature:Detection Alerts Security Solution Detection Alerts Feature release_note:fix v7.11.0 v8.0.0 labels Dec 23, 2020
@banderror banderror marked this pull request as ready for review December 23, 2020 19:50
@banderror banderror requested review from a team as code owners December 23, 2020 19:50
@banderror banderror requested a review from a team December 23, 2020 19:50
Copy link
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

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

This looks great! I need to pull down to test, but wanted to just leave some initial thoughts after a quick glance.

Is it possible to make the callout an accordion. I know that's not currently available in EUI, so not sure if it's possible, but that would make things look a lot less busy I think. @marrasherrier might have more thoughts about showing multiple callouts on the page.

I see the error in the screenshots about not having read privileges on the .lists index. I need to dig in a bit more but I'm curious what functionality (other than lists) that could affect (this might be more of a separate issue to address). I mention it because in one we're using a callout, in the other a toast though both relate to permissions issues.

@@ -14,16 +14,16 @@ const readOnlyAccessToAlertsMessage: CallOutMessage = {
type: 'primary',
id: 'read-only-access-to-alerts',
title: i18n.READ_ONLY_ALERTS_CALLOUT_TITLE,
description: <p>{i18n.READ_ONLY_ALERTS_CALLOUT_MSG}</p>,
description: i18n.readOnlyAlertsCallOutBody(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice - I'm guilty of not following the docs and not using all caps when it's a function.

@banderror banderror force-pushed the fix-closing-signal-fail branch from 77d3865 to adeebbe Compare December 28, 2020 12:37
@banderror banderror force-pushed the fix-closing-signal-fail branch from adeebbe to 1bc9a89 Compare January 4, 2021 13:26
@banderror
Copy link
Contributor Author

Thank you for review @yctercero !

Is it possible to make the callout an accordion. I know that's not currently available in EUI, so not sure if it's possible, but that would make things look a lot less busy I think. @marrasherrier might have more thoughts about showing multiple callouts on the page.

Yeah, that's similar to "Further rework towards cases-like implementation?" comment. I'll discuss with @peluja1012 and hopefully we'll plan it for some of the next releases. Accordion - didn't think about it, but cool idea!

I see the error in the screenshots about not having read privileges on the .lists index. I need to dig in a bit more but I'm curious what functionality (other than lists) that could affect (this might be more of a separate issue to address). I mention it because in one we're using a callout, in the other a toast though both relate to permissions issues.

Oh yes, that's a great comment. If there's some issue with privileges for .lists or .items, we show a toast with error. Which is not super descriptive and the user definitely can't do anything about it. I think we should build some unified way of checking permissions and communicating issues with them to the user. Probably based on callouts, but not necessarily. Maybe even common for the whole app, because the user uses the whole app rather than only detections tab. This one is also a separate topic and I'll chat on it with @peluja1012

@banderror banderror requested a review from yctercero January 4, 2021 18:40
@banderror banderror force-pushed the fix-closing-signal-fail branch from 1bc9a89 to d2afcac Compare January 5, 2021 15:50
@banderror banderror requested a review from spong January 5, 2021 19:56
@banderror
Copy link
Contributor Author

@spong @yctercero @peluja1012 please re-check.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 2160 2165 +5

Async chunks

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

id before after diff
securitySolution 8.5MB 8.5MB +4.4KB

Distributable file count

id before after diff
default 47252 48012 +760

History

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

{text}
</EuiLink>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that there's already an ExternalLink component found here - x-pack/plugins/security_solution/public/common/components/links/index.tsx - we may want to make use of that one, or move this one into that file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, this file seemed too busy for me and containing specific implementations like HostDetailsLinkComponent, so I overlooked ExternalLink there.

I'll check how it works and looks with the ExternalLink component from x-pack/plugins/security_solution/public/common/components/links/index.tsx and try to submit some quick improvement if possible.

Copy link
Contributor

@yctercero yctercero left a comment

Choose a reason for hiding this comment

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

LGTM - some minor stuff that can be addressed in follow up. Definitely curious how we deal with privilege issues with other stuff like .lists and seeing if we can create a unified experience for it (as opposed to sometimes callouts, sometimes toasts, etc).

Thanks for this change!

@yctercero yctercero merged commit 933c6a5 into elastic:master Jan 5, 2021
yctercero pushed a commit to yctercero/kibana that referenced this pull request Jan 6, 2021
…ith reduced privileges" (elastic#86908)

## Summary

This PR introduces the following changes. If the user has insufficient write privileges on the signals index:

- we disable the status-changing actions on detection alerts ("Open alert", "Close Alert", "Mark in progress") in the context menu of an alert in alerts table
- we make sure to show the corresponding callout that tells about read-only access to detection alerts
- in the callout we provide links to docs for understanding why/how to fix
yctercero pushed a commit to yctercero/kibana that referenced this pull request Jan 6, 2021
…ith reduced privileges" (elastic#86908)

## Summary

This PR introduces the following changes. If the user has insufficient write privileges on the signals index:

- we disable the status-changing actions on detection alerts ("Open alert", "Close Alert", "Mark in progress") in the context menu of an alert in alerts table
- we make sure to show the corresponding callout that tells about read-only access to detection alerts
- in the callout we provide links to docs for understanding why/how to fix
yctercero added a commit that referenced this pull request Jan 6, 2021
…ith reduced privileges" (#86908) (#87414)

## Summary

This PR introduces the following changes. If the user has insufficient write privileges on the signals index:

- we disable the status-changing actions on detection alerts ("Open alert", "Close Alert", "Mark in progress") in the context menu of an alert in alerts table
- we make sure to show the corresponding callout that tells about read-only access to detection alerts
- in the callout we provide links to docs for understanding why/how to fix

Authored-by: Georgii Gorbachev <[email protected]>
spong pushed a commit that referenced this pull request Jan 6, 2021
…ith reduced privileges" (#86908) (#87413)

## Summary

This PR introduces the following changes. If the user has insufficient write privileges on the signals index:

- we disable the status-changing actions on detection alerts ("Open alert", "Close Alert", "Mark in progress") in the context menu of an alert in alerts table
- we make sure to show the corresponding callout that tells about read-only access to detection alerts
- in the callout we provide links to docs for understanding why/how to fix

Co-authored-by: Georgii Gorbachev <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
@banderror banderror deleted the fix-closing-signal-fail branch January 6, 2021 14:23
banderror added a commit to banderror/kibana that referenced this pull request Jan 6, 2021
banderror added a commit that referenced this pull request Jan 6, 2021
…87516)

## Summary

This is a follow-up PR addressing some of the comments in:

- #86908
- #87004
banderror added a commit to banderror/kibana that referenced this pull request Jan 6, 2021
…lastic#87516)

## Summary

This is a follow-up PR addressing some of the comments in:

- elastic#86908
- elastic#87004
banderror added a commit to banderror/kibana that referenced this pull request Jan 6, 2021
…lastic#87516)

## Summary

This is a follow-up PR addressing some of the comments in:

- elastic#86908
- elastic#87004
banderror added a commit that referenced this pull request Jan 7, 2021
…87516) (#87549)

## Summary

This is a follow-up PR addressing some of the comments in:

- #86908
- #87004
banderror added a commit that referenced this pull request Jan 7, 2021
…87516) (#87550)

## Summary

This is a follow-up PR addressing some of the comments in:

- #86908
- #87004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Detection Alerts Security Solution Detection Alerts Feature Feature:Detection Rules Security Solution rules and Detection Engine release_note:fix Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v7.11.0 v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants