-
Notifications
You must be signed in to change notification settings - Fork 146
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
[DESIGN][Agent] Minimizing Elastic-Agent privileges #147
Comments
Pinging @elastic/agent (Team:Agent) |
I believe that in a k8s environment |
Is this issue focused on Uptime? In any case I think this is a risky assumption, a user of Elastic Agent for any use-case may decide to install a different integration in the future that may need further privileges, if they do, they will probably find weird failures, and they will end up having to replace their installation of Elastic Agent, or run multiple of them, what may undermine the user experience intended with Agent/Fleet. The default experience should assume that Agent can run any integration. As a process supervisor, it should be understandable that its default is running full privileged. There can be options to run with less privileges, and we should document them, but we have to think on this as unified user experience, considering what happens if a user associates a policy with an agent that doesn't have privileges to run it.
This would also undermine the experience intended with Agent/Fleet. What is the benefit of this new experience if you still need to run agents individually?
I consider this a good practice for any application, but I think it'd be better if we don't rely on this to ensure the minimum privileges principle. I would propose a security model where Elastic Agent has the control of the privileges of the processes executed. The main reasons for that:
This model would be based on:
In some restricted k8s environments |
All good points @jsoriano, however, one concern @joshbressers has had is that users may be reluctant or unable to run the docker container as root, esp. in large environments with strict security policies. I'd argue that elastic-agent is less akin to WRT how the processes are invoked, I agree it'd be nice to have |
Yes, you are right, Agent being a process supervisor is an implementation detail, nothing that a user can see as a reason to have more privileges.
Yes, this could be a good idea in any case. |
I think for now, given the valid concerns @jsoriano has raised, let's proceed with merging elastic/beats#27878 , and postpone future work for now. That solves the use cases we need on our team, and we probably don't have the bandwidth for a larger scale fix at this point. |
I'm taking a look at having the I would like us to revisit that decision, ideally allowing beats to specify which user:group they would like to be run as, instead of requiring each individual beat to implement the logic that heartbeat currently has to change its user:group and optionally set specific capabilities. Ideally, the name: APM-Server
cmd: apm-server
artifact: apm-server
...
user: elastic-agent
group: elastic-agent
# APM server doesn't require any additional capabilities, but they could be specified as:
# linux_capabilities: 'cap_net_raw+ep' Another option would be to recommend that the |
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
I am not sure if there has been an active decision on this after this issue was opened. This is only the way it currently works.
+1 to this, this would be in line of my proposal in #147, where Elastic Agent controls the privileges, based on info given on each collector spec. I don't think that an approach like this one has been discarded, only that it would need more work. |
@ruflin seems to be a requirement to consider for the V2 design you are doing. |
@jlind23 I added a note to the design doc to dig into it. |
@jsoriano , please take in mind that the current In platforms like The following small change solves the problem:
The previous just changes the group ownership of the At the moment we are |
@ph This is something we may consider to avoid having issues on cloud container solutions such as azure containers.. |
@eedugon these changes to add files and users to the root user group were done in the context of supporting OpenShift guidelines, you can read more about this in elastic/beats#12905 (reverted and reapplied in elastic/beats#18873). If we change this to support Azure, we have to check that we keep supporting these OpensShift guidelines. |
@blakerouse @ruflin what is your opinion here? Any particular path we should take? |
If I understand the guideline, making that change will be incompatible with openshift.
From: https://docs.openshift.com/container-platform/4.9/openshift_images/create-images.html |
Thanks Jaime!
root group membership isn’t that important, just with a directory ownership
change the image would work in Azure (although depending on the openship
requirements I don’t know if that would break openshift compatibility).
What looks weird to me is trying to run our software with “non root” users
but adding the user to the root group.
Anyway I’m totally ok with any decision you take here, but it would be
great to add in the docs the container environments that we verify or
support.
El El jue, 27 ene 2022 a las 20:48, Pier-Hugues Pellerin <
***@***.***> escribió:
… If I understand the guideline, making that change will be incompatible
with openshift.
For an image to support running as an arbitrary user, directories and files that may be written to by processes in the image should be owned by the root group and be read/writable by that group. Files to be executed should also have group execute permissions.
From:
https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html
—
Reply to this email directly, view it on GitHub
<elastic/elastic-agent#147>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGBFXJLA32MJEF7FSD7YIVDUYGOP5ANCNFSM5EAEATFQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
You are right Pier-Hugues, sorry I hadn’t read your post.
So clearly my workaround is against openshift, and the reason for the user
to be on “root” group is probably beyond my understanding.
Sorry for the noise here!
The openshift guideline also explains:
Because the container user is always a member of the root group, the
container user can read and write these files.
I don’t know if that’s generic on Linux dockers or it’s just an openshift
proposal, just looked weird from sysadmin and security point of view.
El El jue, 27 ene 2022 a las 20:54, Edu Gonzalez de la Herran <
***@***.***> escribió:
… Thanks Jaime!
root group membership isn’t that important, just with a directory
ownership change the image would work in Azure (although depending on the
openship requirements I don’t know if that would break openshift
compatibility).
What looks weird to me is trying to run our software with “non root” users
but adding the user to the root group.
Anyway I’m totally ok with any decision you take here, but it would be
great to add in the docs the container environments that we verify or
support.
El El jue, 27 ene 2022 a las 20:48, Pier-Hugues Pellerin <
***@***.***> escribió:
> If I understand the guideline, making that change will be incompatible
> with openshift.
>
> For an image to support running as an arbitrary user, directories and files that may be written to by processes in the image should be owned by the root group and be read/writable by that group. Files to be executed should also have group execute permissions.
>
> From:
> https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html
>
> —
> Reply to this email directly, view it on GitHub
> <elastic/elastic-agent#147>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AGBFXJLA32MJEF7FSD7YIVDUYGOP5ANCNFSM5EAEATFQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Yes, this seems to be the case for containers started with Docker with arbitrary uids:
And yes, this effectively allows to access (mounted) host files with permissions for the root (0) group. What I think that OpenShift additionaly does is to use user namespacing, this way the id 0 in the container belongs to a random unprivileged user and group in the host. (Update, more info about this: https://cloud.redhat.com/blog/a-guide-to-openshift-and-uids, https://cookbook.openshift.org/users-and-role-based-access-control/why-do-my-applications-run-as-a-random-user-id.html) |
@jsoriano Is that correct to believe that we might need to have a different docker images for the azure case? |
Yes, it may be possible that we need an specific image for Azure if their runtime is different enough. We would need to investigate a bit more. |
@ph first thing to do will be to have a single config running on both openshift and azure container, and if it's not working then we should consider shipping a specific azure image which i will definitely try to avoid. |
Is this FR / issue still alive? As a user, I would like to be able to set which user context each integration executes as. For example, we can run Filebeat today as a service on Windows with a specific user to access files and folders that cannot be accessed by system. This is a slight blocker for us to migrate a few different integrations. A work around is deploying an agent locally to said systems but we would prefer to use network mapped drives (even though discouraged, this works very well) to reduce overhead on the servers themselves and have less agents to manage. Also, it's best to have reduced permissions anyways, especially when you are simply reading log files and forwarding them on to another resource. Please do let me know if this concept is worth considering here or a new issue/FR makes sense. Thanks! |
Elastic Agent can now be run as non root on Linux, Mac and Windows hence closing this as done. |
Action plan after meeting today with @blakerouse @fntlnz and @justinkambic
There are three use cases for elastic-agent with different security requirements, where we can have three different behaviors.
For docker containers specifically, we need a clear path to running as non-root for two reasons:
New Behavior by Use Case
Install command on local machine
Run in docker with
docker run
elastic-agent
setcap
to add privileges to theelastic-agent
binarysetcap
as neededRun in kubernetes
Tasks:
The text was updated successfully, but these errors were encountered: