-
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
The removeReferencesTo
function doesn't check authorization correctly
#135259
Comments
Pinging @elastic/kibana-core (Team:Core) |
Pinging @elastic/kibana-security (Team:Security) |
Pinging Security folks because it feels like related to the SOC wrapper as well? |
@legrego @azasypkin Just want to clarify something. Should this be an all or nothing operation? If the user is not authorized to update ALL of the referencing objects but is authorized to update SOME, should we abort or should we update the objects for which the user us authorized? Use case given is deletion of a tag. If we cannot remove all of the tag references, but proceed with the deletion of the tag, what ultimately happens to the orphaned references to the deleted tag? I assume this will cause some problems. And if we proceed with removing SOME of the references, and then bypass the tag delete (not sure we can do this currently with existing returns) we're still left with an undesired result. In other use cases, partial authorization may not be a problem. @elastic/kibana-core As this is a data integrity question, could we get some input on this? UPDATE: additional question, should |
To summarise the slack conversation. There's two ways that a plugin might use
So for the one use case we have today it feels like the behaviour is correct/sufficient. To ensure it's not abused we could consider making |
Thanks @rudolf! After discussing with @elastic/kibana-security, we're ok leaving the existing behavior. We can re-evaluate in the future, given additional use cases and referential integrity considerations. For now, I will update the method documentation with intended usage details and a link to this issue/discussion. |
## Summary Updates comments for `removeReferencesTo` (SO Repository) and `authorizeRemoveReferences` (SO Security Extension) methods with remarks regarding the intended use and authorization. Currently the only use case for `removeReferencesTo` is the delete method of the tags client. If the authorization check is changed to authorize an update for each referencing object, lingering references in objects which the user is not authorized to update may be left behind when a tag is deleted. We will leave the current implementation in place until a decision about if & how to manage referential integrity occurs. This PR documents the current intended use case for `removeReferencesTo` as: "to provide clean up of any references to an object which is being deleted (e.g. deleting a tag)." See issue #135259 and discussion [here](#135259 (comment)), for background.
With no plans to address, closing this issue |
Kibana version: 7.11+
Describe the bug:
This bug was introduced when the Saved Objects Tagging feature was added in #79096.
The Saved Objects Client (SOC) exposes a
removeReferencesTo
function that allows you to remove all references to a given object. Under the hood, it uses the Elasticsearch client'supdateByQuery
functionality to achieve the desired result.There are two problems:
This isn't a practical problem right now as the only consumer is the TagsClient, and we consider tags to just be metadata. However, other consumers could adopt
removeReferencesTo
in the future and this could pose a security risk.Steps to reproduce:
See the integration test for deleting tags:
kibana/x-pack/test/saved_object_tagging/api_integration/security_and_spaces/apis/delete.ts
Lines 37 to 46 in f466ebf
In that test assertion, the call to
TagsClient.delete
fails duringremoveReferencesTo
:kibana/x-pack/plugins/saved_objects_tagging/server/services/tags/tags_client.ts
Lines 65 to 72 in 3730dd0
Expected behavior:
This function should be refactored to (1) search for all "inbound references", (2) check privileges for each of those referencing objects, and (3) bulk update any of those that the user is authorized to change. This effectively means that
removeReferencesTo
would behave more like thefind
function and never experience a 403 error when calling it. If/when that change is made, the integration test above will continue to work, because the authorization check will still fail during the subsequentdelete
function call for the tag itself with the same error message.We made a similar change for the "Delete space" API recently (#124145).
Such a change for
removeReferencesTo
is impractical now with the current paradigm of "SOC wrappers", but we are undertaking a major refactor that will remove the wrappers and move this functionality into the Saved Objects Repository (#134395). Once that is complete,removeReferencesTo
authorization/auditing can be changed with ease.Any additional context:
When an authorization check for
removeReferencesTo
fails, the error message that is returned is currently "Unable to delete ". We are currently undertaking a major refactor of the SOC and its wrappers in #134395, and in that proof-of-concept PR I have change that authorization check. Now the failure message is "Unable to update ". The authorization check is a little less wrong -- even if, in practice, a user will never be able to update an object without deleting it -- but the authorization check still needs to be fixed.The text was updated successfully, but these errors were encountered: