-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Feature Request] Create a mechanism to track if the current execution is within a block where the ThreadContext has been stashed #14733
Comments
Thanks for the feature @cwperks
I believe thread context stashing is used in many, many different places and is not really related to plugin, but probably more generic to "caller", it is used heavily by
But to the point, I believe the thread context is not the place where any authorization decisions could be made, but the
It could be done using the
This statement is unclear to me, the "authenticated user" concept is (at least for now) strictly specific to |
The best analogy is that stashing the threadContext is equivalent to running a command as Effectively, a plugin has switched contexts and is allowed to perform any action on the cluster as
This is forward looking outside of the stronger system index authz that I have been working on. Essentially, instead of running as For these 2 PRs:
It will provide an off-ramp for plugins to remove usages of stashContext in favor of switchContext which is essentially identical, but it populates the threadcontext with plugin info so the security plugin can authz transport actions accordingly. |
I think the
I still don't understand this, sorry, what kind of actions? We do have plugin security policy in place, plus permissions that security plugin manages. I think you have larger picture in mind but for some reasons reference to low level thread context hides it (it is just a means but not the solution). |
Transport actions. |
This is where we have permissions, right? |
For users yes, but not when plugins stash the threadcontext. When a plugin stashes the threadcontext, any action initiated in the block is implicitly trusted. In the security plugin, there is a bypass for this scenario so that a plugin can perform elevated actions such as writing to a system index. |
Consider this pseudo code for creating an anomaly detector. Creating an anomaly detector indexes a document into the
|
So it seems like the plugin have to be explicitly allowed to do that, if allowed at all, right? With that, it fits perfectly into the security policy model we have at the moment. Reject context stashing by default, allow when explicitly granted. |
There could certainly be a permission entry in the |
I think transport actions and thread context are quite unrelated. To me, the proper implementation of the latter model would be to introduce identity to plugins and extensions, so we could apply the same permission model (that |
That's more or less what this PR will accomplish: #14630 When switching contexts, it populates info about which plugin has switched contexts. With the companion Security PR it demonstrates how that info would be used to more strongly protect system indices. With those 2 PRs, plugins would be limited to transport actions that directly interact with system indices registered by the respective plugin. |
I think we are still trying to "hack" the way though but not design the solution, I don't see anywhere:
|
[Triage - attendees 1 2 3] An alternative could be building up the identity framework so that plugin/extensions can take on its identity of itself vs the user using high level concept. |
@peternied re-opening this issue to continue discussion on a solution |
@cwperks I would recommend creating an RFC to describe the problem and build consensus. This issue as filed was rejected and should stay closed. |
For a plugin the identity would be the canonical class name for the class that
It is not exposed. The PluginsService has a list of the installed plugins and is able to keep track of all installed plugins and their canonical class names.
It does not (at least with the open PRs). When a plugin switches contexts it would only be permitted to perform actions that interact with its registered system indices. Its definitely possible to map the plugins identity to permissions to permit it to do more if there's demand for allowing plugins to perform additional actions outside of an authenticated user context. The Open PRs provide an off-ramp, not an end state solution. There will be refactoring in plugins that need to take place. I don't want to expose the raw thread context to plugins and instead expose APIs within the PluginAwareNodeClient that can be sanitized to prevent plugins from populating certain headers. |
@cwperks I would like to +1 @peternied suggestion: this issue will not bring us to any solution since the problem statement is not set at the right level. |
@peternied There is an open RFC: opensearch-project/security#4439 Please chime in with your thoughts. |
Again, the RFC focuses on very low level details, it is not designing (as per #14733 (comment)) any base abstractions to approach the problem and later on, suggest the APIs / implementation changes required (it looks reversed to me, sorry) |
Thank you for all the feedback. I will rework the RFC to reflect the latest thinking around PluginAwareNodeClient, how its passed to plugins and what it will expose. I've been iterating trying different ways to solve the problem so I probably started too low level. Hopefully the problem statement is clear that plugins are implicitly trusted and there should be better mechanisms in place. I've been thinking a lot about extensibility and how to simplify the plugin developer experience when working with Security and Job Scheduler while making the ecosystem more secure simultaneously. |
Correct, so we need to define the identity model for plugins and extensions (please do not ignore them, unless we make a decision to phase them out, those are equally important and need to be represented). |
Sorry if it was unclear from earlier replies. The open PRs put forward a proposal to populate a header called
While not done in that PR itself, I would also like to add higher-level APIs around the threadcontext to prevent certain headers from being populated by plugins. Come to think of it, I may be able to move this check into an ActionFilter in core and have core provide the protection even if security is not installed. |
Out-of-process extensions have a separate flow for differentiating requests made on-behalf-of the authenticated user and when the Related META issue: opensearch-project/security#2944 |
Thanks @cwperks (I forgot about that), I believe the plugins should have an similar kind of identity (or even the same kind of service account based identity), which would be granted based on the execution flow (since plugin could have user initiated flow or not). |
Is your feature request related to a problem? Please describe
Related RFC in the security plugin: opensearch-project/security#4439
I would like to have a mechanism to track which plugin most recently stashed the ThreadContext. Stashing the threadContext is done in the plugin ecosystem in order to allow a plugin to interact with its system indices when the security plugin is installed.
Stashing the threadContext is analogous to running a command as
sudo
. A plugin that stashes its threadContext is effectively switching contexts, that is instead of running in an authenticated user context its running in an elevated context.By being able to keep track of where the ThreadContext was most recently stashed, it would be possible to provide richer authorization mechanisms within the block where the threadContext was stashed.
Better authorization includes:
Describe the solution you'd like
Have some sort of lookup to query if the current execution is within a block where the threadContext is stashed and identify the plugin that stashed the context.
Related component
Plugins
Describe alternatives you've considered
Keep the existing implementation
Additional context
Related RFC in the security plugin: opensearch-project/security#4439
The text was updated successfully, but these errors were encountered: