-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Incorrect privilege warning when creating Custom Rule #211123
Comments
Pinging @elastic/security-detection-engine (Team:Detection Engine) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
@pborgonovi can you please share the official permissions of the user in question?
I ask because in trying to reproduce this I noticed that copy/pasting index patterns into the "Create Roles" UI lead to index patterns with extra whitespace. This did cause the rule execution to (correctly) say that my user did not have permission, but ultimately this was due to an issue with the role, and not our permissions logic. The fact that you have a seemingly empty index pattern in your screenshot leads me to believe this might be the case here. It's interesting that I suspected that this might be a bug where we incorrectly reported lack of read access to indices which do not exist, but I was able to disprove this with the following example:
With the above script, I did not see any read errors, which proves that we are not checking privileges for non-existent indices. The presence of auditbeat data, and my observation that we do check for its read access during rule execution, verified to me that this is working as expected. @pborgonovi one more note that might help diagnose what's going on here: toggling a rule on/off does not reset its API token (so the rule would continue operating with a "previous" set of privileges); you need to edit the rule and perform a substantive change for new privileges to be picked up. |
Hey @rylnd
There we go:
I reproduced the same steps you mentioned above:
Created a fresh Cloud deployment
![]()
![]()
![]()
Ingested auditbeat data: ![]() Ran the rule again: ![]() Am I missing something here in the steps? |
@pborgonovi did you see a failure in step 4, before adding auditbeat data? Was this performed on a fresh install? @pborgonovi I've only tested this with a local dev build on |
Hey @rylnd
No failures in step 4. It was performed on a very fresh install.
I've been testing on Cloud with latest BC but can try to reproduce it locally on main. (get back to you soon) In the meanwhile, I also tried the following:
![]()
![]()
![]() |
@pborgonovi are you implying that this is how the original privileges were created? Presumably you selected the long index pattern from the Index Privileges picker in the Role UI, right? If so, this does appear to produce a different set of privileges than selecting those patterns individually. By selecting that long pattern I get the following privileges: GET _security/user/_privileges
# Response =>
{
"indices": [
{
"names": [
".alerts-security.alerts-default,apm-*-transaction*,auditbeat-*,endgame-*,filebeat-*,logs-*,packetbeat-*,traces-apm*,winlogbeat-*,-*elastic-cloud-logs-*"
],
"privileges": [
"read",
"write"
],
"allow_restricted_indices": false
}
]
} Compared to entering patterns individually: GET _security/user/_privileges
# Response =>
{
"indices": [
{
"names": [
"-*elastic-cloud-logs-*",
".alerts-security.alerts-default",
"apm-*-transaction*",
"auditbeat-*",
"endgame-*",
"filebeat-*",
"packetbeat-*",
"winlogbeat-*"
],
"privileges": [
"read",
"write"
],
"allow_restricted_indices": false
}
]
} This is important because of how we check the user's privileges. Our logic can be summarized as:
The reason the form of these privileges seems to be important is because of how we perform the check in 2b. It's effectively: POST _security/user/_has_privileges
{
"index": [
{
"names": [
"auditbeat-*",
"filebeat-*"
],
"privileges": [
"read"
]
}
]
} Where In the multi-pattern role, with multiple index names/patterns, the above I'm not yet sure if this is a bug in the privileges API, whether this is due to our misuse of that API, or whether one of those sets of privileges is incorrect. We'll need to do some investigation to figure out which is the case. |
Yeap, this is the difference I noted too. After going through these steps with you I can understand it's likely to be an issue on privilegies side. Thanks for the investigation. |
@pborgonovi it looks like this might be the relevant issue here (found via https://github.com/elastic/sdh-kibana/issues/3022). As is presented there, it's arguably a bug that we allow users to create these types of ineffective privileges, but the issue is more central to Kibana than the Detection Engine. If the "correct" privileges work as expected (which they appear to), I could see this being added to a "known pitfalls" section of documentation. We could potentially also perform a check during rule execution to identify this; it should be as simple as checking whether their index privileges' names contain a |
@rylnd That makes sense. @yctercero how should we handle this with documentation? |
cc @nastasha-solomon as she may have an idea of where to slot this in documentation |
@nastasha-solomon do we have a troubleshooting section to add this to? |
Hey, thanks for the ping. There is this troubleshooting page that's generally used for detection rule issues. I'd just need to add a new section for custom rules. If someone can file a doc issue in the |
@nastasha-solomon I created elastic/docs-content#599 👍 |
Description:
When creating a custom rule with an index pattern that matches the indices already included in the user’s read and write permissions, a warning message incorrectly states that the rule may not have the required read privileges for certain indices.
Kibana/Elasticsearch Stack version:
8.18 BC3
Functional Area (e.g. Endpoint management, timelines, resolver, etc.):
Detection Rules RBAC
Pre requisites:
read
andwrite
access to the following indicesSteps to reproduce:
“This rule may not have the required read privileges to the following index patterns: [”-elastic-cloud-logs-”,“apm--transaction”,“endgame-”,“filebeat-”,“packetbeat-”,“traces-apm”,“winlogbeat-*”]”
Current behavior:
A false warning message appears, incorrectly suggesting that the user may not have the required privileges for certain index patterns, even though they are explicitly listed in the access role.
Expected behavior:
Since the user already has read and write access to these indices, no warning should be displayed.
Screenshots:
The text was updated successfully, but these errors were encountered: