-
Notifications
You must be signed in to change notification settings - Fork 119
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
Drop all capabilities by default in Elastic Agent containers #1794
Conversation
@@ -18,6 +18,8 @@ services: | |||
- {{ . }} | |||
{{- end }} | |||
{{ end }} | |||
cap_drop: | |||
- ALL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about trying to drop all capabilities also in the main docker compose, and test with integrations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll update those scenarios and run a test with integrations.
Wondering what to do in the template used for custom agents (servicedeployer). For that case, packages could also define some cap_drop
. It's also true that until now some capabilities are just added with cap_add
. But looking at the code of moby
, if ALL is present in cap_drop , all capabilities are drop...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are no issues when cap_drop ALL is set:
elastic/integrations#9694
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update also custom agent template ? As there are no packages using cap_drop
in the integrations repository, probably it's a good idea, WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea.
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#9694 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
test integrations |
Created or updated PR in integrations repository to test this version. Check elastic/integrations#9694 |
💚 Build Succeeded
History
cc @mrodm |
Part of #787
In docker/docker-compose there are some capabilities that are added by default to every container (https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities).
This PR ensures that agents are started with the minimum required capabilities, dropping by default all of them.
If
ALL
it is defined incap_drop
field, then it just adds the Linux capabilities for the container defined incap_add
:https://github.com/moby/moby/blob/82d8f8d6e6dbc88ed437b8bf6c38399b46ba7d93/oci/caps/utils.go#L112-L114