-
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
[Discussion][Security Solution] Enforcing unique rule_id
's within Integrations' security-rule
Saved Objects
#128202
Comments
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
Pinging @elastic/fleet (Feature:EPM) |
Thanks @spong for the write-up.
This is not so uncommon under some circumstances. For example we found this kind of issues quite frequently in early versions of Fleet when migrating assets from Beats to integrations. Users of Beats found id conflicts when trying to use integrations in the same cluster. This may happen here too if security rules are migrated from an existing solution without changing ids as part of the process.
This can be enforced in the package spec, we have a similar check for kibana dashboards, where we check that their ids are prefixed with the package name. We could do something similar here. Package spec validation is run during CI at least in packages whose source is in the integrations repo. And for all packages before publishing them. Regarding the proposed solutions, I think that something like point 3 should be implemented in any case. Trying to install an asset with the same id as an existing one shouldn't fail transparently (neither should it overwrite the previously existing asset without telling anything to the user). Point 4 is not very practical. Take into account that sooner or later, the public package registry is going to contain several thousands of packages and versions, for such a check you may need to download all these packages and check their contents, producing quite an overhead in the development process. I think that if possible to have ids prefixed with the package name we should go for option 1, as this is a known solution we are also applying to other resources, and this is something we can check when publishing any package independently of the development process used by the maintainers of the package. We will need to see how to handle existing packages. |
Thank you for clarifying some of my assumptions above @jsoriano! 🙂
This is good to know, thank you! This scenarios makes sense and would still be applicable to security, although I imagine more-so for 3rd party integration developers than internally since we centrally manage most security rules. That said, this will definitely increase in scope if other solutions adopt this same way of delivering pre-packaged rules via integrations.
Perfect! Will add this to the proposed solutions as the extra coverage here will at least protect an individual package from duplicating their own
Yeah, I was thinking more-so a dev documentation update so 3rd party devs following along could follow how they can correctly bundle security rules with their integration. Definitely makes sense why CLI tooling wouldn't work here 👍 |
Alrighty! So from our discussion today we ended up with a mish-mash of the proposed solutions from above. To summarize though:
And lastly lastly, it was agreed none of these changes would need to happen immediately (since we've verified unique ID's across the existing packages shipping If I have mis-conveyed any of the above, or if there are any further questions please comment here. I'll keep this issue open for a little while longer for this feedback, and if we're all good will go ahead and close this in favor of the three issues outlined above. Thank you everyone for you valuable feedback and input here! 🙂 |
On behalf of the Integrations Ecosystem team responsible for tooling and Package Storage maintenance, I must decline this idea due to multiple reasons:
As we are code owners of the Integrations, Package Storage, Elastic Package, Package Spec, please keep us in the loop (@elastic/ecosystem). FYI This thread fits better the Package Spec repository, which is the discussion point for all initiatives around packages and Fleet. Please consider moving it there. Thank you. |
There's what now?! 😮 🤯 Well then, that makes this whole thing a non-issue?? That code ensures Of course my test environment may not be an accurate representation of how this is supposed to work, so sounds like it might be good for us to have a chat -- I'll reach out next week and we can discuss further 🙂 As an aside (and probably irrelevant now), in your response to the proposed solution, I believe there's a misunderstanding as the intent was not to check "everywhere" if a single rule ID doesn't cause a conflict (which @jsoriano pointed out as not feasible in elastic/integrations#2115 (comment)), but rather check only the assets included in an individual package to ensure their
If it's okay I'm going to keep this in the Kibana repo until we have a chance to chat next week as I don't want to waste anymore of anyone's time until we can level-set on the facts here. Once we chat, if this still warrants an issue I'll go ahead and open a dedicated issue in the Package Spec repo with all the details distilled so folks don't have to go through any irrelevant/inaccurate information. 👍 |
Package validation according to the spec format is a procedure executed statically without the requirement of running Elasticsearch or Kibana. The procedure needs ~1s to check if the package is valid and scales well.
I will pass this question to @joshdover, but add my few cents. Such logic wouldn't be a proper validation mechanism, but rather an object conflict prevention method. It can't be the ultimate decision-making process as it's impossible to install ALL packages (consider the 1kk target). |
I can't really speak to the original intention when this code was written but it appears it's always worked this way. I know there is one case where we do want to overwrite SOs, which is when creating the One question I have is: why do we need IDs in the SOs defined in packages at all? There are two use cases cases I'm aware of where this is depend upon:
We definitely need to support these use cases, but is there an actual need for the ID in the package to actually match the ID that we end up creating the objects with at install time? Would it be acceptable to re-generate IDs when we install SOs and then provide an API in Kibana for translating the ID defined in the package to the ID the object was installed with?
As of 8.0, all Saved Objects now have globally unique IDs so I don't believe we need to consider this explicitly. Fleet does not yet really support installing package SOs into multiple spaces, but the idea in the future is that we would allow users to share the same SO across multiple spaces. We're tracking this as part of #99116 but are blocked on waiting for Dashboards to become share-capable. |
I can confirm the above reasons. Not sure if there are any other, but we learnt about these the "hard way", breaking product :)
I expect that the SO format will change then, right? If we can ensure BWC with the older package, and the new translation logic will be aware of legacy packages, then I guess that we're good to go. |
Thanks for the context/history @joshdover & @mtojek!
So on the Security Solution side (Detections specifically, as I can't speak for Endpoint), we don't have a direct need for specifying the That said, I brought this up with the team in our weekly today and in effort to provide a holistic solution around Pre-packaged Rule Assets (not specific to just Security Solution, so we can hopefully remove that special handling you mentioned @mtojek ) @XavierM on the ResponseOps side is going to schedule a meet-and-greet for us all (ResponseOps, Security, O11y, and you folks on the Fleet/Ecosystem side) so we can touch base, meet the parties at play, and go from there. |
👍
It may not be so simple to perform, because we need to ensure backward compatibility with older stacks. If you remove this rule from spec and developers start following it as "there is no special handling anymore", there is a risk that somebody will accidentally break the installation on an older stack. To fully enable this option, we may need to release a major spec release and validate assets format depending on compatible Kibana stacks (package version constraints). If we want to follow that path, it's another internal discussion for the spec committee. |
Summary
With the introduction of the
LotL Attack Detection
package (elastic/integrations#2115), we'll now have two packages that are bundling Security Detection Rule assets that can be installed within the Security Solution App (the other being thePrebuilt Security Detection Rules
package).One constraint of Security Detection Rule's is that they each must contain a unique
rule_id
, an identifier that can be thought of as anexternal id
that remains static as the asset traverses different systems, or is exported/re-imported, etc. Thisrule_id
(along with the SOid
) must remain unique per Kibana space. If a rule is duplicated, a newrule_id
is generated. Thisrule_id
also aids in features like displaying all alerts that a rule has ever had, e.g. on the Rule Details page we query for alerts by this id and can show all alerts from past instantiations of the Rule in cases where it was exported, deleted, re-imported, etc.Open Question
With the introduction of a second package containing
security-rule
assets, and with more to come, the open question for discussion here is how do we ensure uniquerule_id
's across all packages shipping Security Detection Rules.Impact
While the impact here is high (where two assets with the same
rule_id
will result in only one installing within the Security App, with no error to the user), the actual chance of this happening is pretty low, and will most likely be the result of developer error when creating/updating packages, or developers using a common string instead ofuuid.v4()
. E.g. creating a new package and copying over existing assets as an example and forgetting to updaterule_id
, or perhaps as a byproduct from the central management of the assets before being added to the package (something which the detection-rules repo checks for).Potential Solutions
Ideally, we'd just have a test that would run within the integrations repo and it would check for any duplicates across all packages before merging, however this fails to take into account that not all packages are hosted in the integrations repo, and that there are packages whose source may be in other repositories (elastic/integrations#2115 (comment)).
So that said, here are a few potential solutions and corresponding changes in UX that users/developers may incur:
1. Prefix
security-rule
(Fleet SO)/detection-rule
(Kibana SO)rule_id
's with package nameThis will help ensure uniqueness between packages, but has the following cons:
Prebuilt Security Detection Rules
package rules (or those would need to be coded as an exception),rule_id
being used within the same package (or would it be possible to add tests before a package can be published to check this @jsoriano?)2. Add package name to
security-rule
/detection-rule
assetsrule_id
uniqueness, and introduces added complexity when importing rules (nowrule_id
wouldn't be static as-is, but would follow special business logic depending on certain fields)3. Display error in UI when installing rules and allow user to pick which to install
4. Add package/integration process docs to ensure developer verifies uniqueness
1.
it's just a process change (and so could be ignored/missed), but we could supply a CLI tool or something they could run to verify ID's against a currently deployed package-registry5. Do Nothing
Please edit this comment and add any additional thoughts/solutions to this list! 🙂
Suggested Solution
Having just typed all these up 😅, I would propose a combination of solutions
3.
/4.
, where we add the appropriate error UI so users can be identified in the unlikely event there is an issue, give them the option to pick which rule to install, and let them know which package owner(s) to reach out to so they can address the issue, and then also add additional package/integration process docs that would support developers creating packages as to further decrease the likelihood of this even occurring in the first place.cc @jethr0null @XavierM @elastic/security-detections-response-rules @alvarezmelissa87 @brokensound77
The text was updated successfully, but these errors were encountered: