-
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
[Fleet] Exposed service to manipulate fleet-*
should use internal ES client
#116182
Comments
Pinging @elastic/fleet (Team:Fleet) |
Thanks @nchaulet for creating this. See here: kibana/x-pack/plugins/fleet/server/plugin.ts Lines 144 to 150 in 0119bd8
FYI: in the endpoint API, for package and agent policy services, we are using an internal SO client to get around the privileges issues, but if these could also abstract away the need to pass one in that would be awesome. See here: Lines 237 to 249 in ed9859a
(don't laugh at the class variable name 😆 ) |
fleet-*
should use internal ES client
I think we should only change services that require access to Though I think this will also depend on whether or not we end up using Kibana application privileges or Elasticsearch privileges to allow non-superusers to access Fleet. If we end up using Kibana privileges, we'll always need to use the internal user and should provide some utility functions for doing authz checks for the current request at the API level.
+1, let's avoid using the request where possible to keep this APIs flexible. This does mean that all consumers of our APIs need to be enforcing authz themselves (with the provided utility APIs) |
I believe we only need to address this when we decide to tackle #108252. Otherwise, it's not a hard requirement for 8.0 since all (super)users of Fleet will already have this privilege so using the client configured with their credentials will continue to work. |
I think it's already a requirement for other plugins consuming Fleet API where the user is not required to be a superuser like endpoint. For the fleet App your are right is not urgent as we require the superuser role. |
💡 Maybe the Fleet exposed services could have a Btw - I assume we would allow this (the ability to pull data out of fleet using the internal kibana user) only for In Endpoint security, we have one flow that updates Endpoint Integration Policy - my assumption is that for that flow (if they ever decided to apply fine-grained RBAC) is that a user would need to have Access in fleet to update that integration. I don't think we (endpoint) would create our own API for that to bypass Fleet privileges requirements |
Yes, but they won't have direct privileges to do things like install index templates, etc. Instead, users will be expected to have a fleet-specific privilege that we check for on Kibana's server-side and if they do, we use the underlying system user to execute the Elasticsearch API calls. The recommended way I have of respecting these privilege requirements would be to call Fleet's HTTP API directly which will always do these authz checks. However in cases where Fleet operations may need to be executed as part of another server-side API, plugins will need to execute the authz checks directly. But like I said, we can provide some utilities to make this easier:
I think we will need (1) anyways for any background operations that may not have a request object, but (2) is likely to be more future-proof, since applications wouldn't need to make any changes as we add additional privilege levels in the future. I know this a bit contrary to what we were saying above, but now that I'm looking at our longer term plans to introduce finer-grained privileges to Fleet progressively, I think (2) is probably the safer option that also requires less cross-team coordination as the privilege model evolves.
Good point 👍 Didn't realize apps were already doing this today. |
I've put up a POC here that implements both a scoped version of the agent service and a internal user version. PTAL: #119017 |
Note that we also need to do something similar for our access to |
Note that #119992 switched over to use the internal user for all accesses to The only other service besides agentsService that requires an ES client is the |
Description
Elasticsearch is restricting how an user can system indices by introducing
allow_restricted_indices
.Fleet expose some services like the agent service that interact with
.fleet-*
indices (system indices. In order to avoid to give users read permissions to the fleet-* index and to avoid bugs we should probably change the signature of the services we expose from Fleet and provide ourself the elastic search client using the kibana system user.Implementation details potential solutions
We have an internal user client available in our
appContextService
that we can use for that.We should probably remove the esclient argument from all of the methods from the agent service see https://github.com/elastic/kibana/blob/master/x-pack/plugins/fleet/server/services/index.ts/#L46-L74
We could also rely on having the request as an argument, I know this make this service a little more hard to consume outside of a request context (like in a background task for example)
The text was updated successfully, but these errors were encountered: