-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[agentbeat] Fix agentbeat capabilities #40466
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
This pull request is now in conflicts. Could you fix it? 🙏
|
) | ||
|
||
func initCapabilities() { | ||
isRoot, err := utils.HasRoot() |
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.
This entire block of code is Linux specific, you don't need to also duplicate the Windows and MacOS HasRoot
implementations. You can just make the implementation of initCapabilities
a no-op on those OSes instead.
If we want to share HasRoot
put them in elastic-agent-libs, the implementation particularly for Windows is non-trivial and has had bugs recently.
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.
I've removed it for other OSes.
Can you take a look?
* chore: add effective capabiltiies in agentbeat * chore: comments * fix: changelog * fix: add license * fix: lint * fix: goimports * fix: remove HasRoot for other OSes --------- Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co> (cherry picked from commit 36cef2f)
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.
I do not believe this should have been merged this way. Overall setting capabilities is not an agentbeat specific thing, it should be set per beat type and only for the types that the specific beat needs. This seems to just be a promote all from from effective and inheritable to the permitted set, from a security perspective this is not great. It should be limiting to only what each beat type needs. Agentbeat itself is not a beat it is a metabeat and should not be in-charge of this work directly.
I also feel like merging this as is, was not the correct thing todo. We have similar logic in Elastic Agent and this needs to be moved to each individual beat so this code should be moved to a generic location first, and not merged to then be moved later. We should strive for cleanliness even if it delays the merge some time. It would also be interesting to know if OTEL already has something like this? If so is it in a library that could be re-used? If not does another library already exist that can be re-used or should be make our own module for this specific logic?
I had been thinking about this PR over the weekend, I was not expecting it to be merged so quickly.
I did an experiment and reverted this PR as in my thinking it shouldn't be necessary for this code to exist in agentbeat. This is because elastic-agent, after merging this PR, when running rootless is raising all capabilities from Bounding set (specified in k8s manifest) to it's Ambient set to allow subprocesses maintain them. As shown below k8s tests with this PR and without the code here are running without failures ![]() |
* chore: add effective capabiltiies in agentbeat * chore: comments * fix: changelog * fix: add license * fix: lint * fix: goimports * fix: remove HasRoot for other OSes --------- Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co>
This reverts commit 36cef2f.
* [agentbeat] Fix agentbeat capabilities (#40466) * chore: add effective capabiltiies in agentbeat * chore: comments * fix: changelog * fix: add license * fix: lint * fix: goimports * fix: remove HasRoot for other OSes --------- Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co> (cherry picked from commit 36cef2f) * Fix the changelog --------- Co-authored-by: VihasMakwana <121151420+VihasMakwana@users.noreply.github.com> Co-authored-by: Denis <denis.rechkunov@elastic.co>
…s" (#40575) * Revert "[agentbeat] Fix agentbeat capabilities" (#40510) * Revert "[agentbeat] Fix agentbeat capabilities (#40466)" This reverts commit 36cef2f. * Update main.go (cherry picked from commit f6b8701) * Update CHANGELOG.next.asciidoc --------- Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
Proposed commit message
agentbeat
to elevate permissions to match the permitted set.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
How to test this PR locally
elastic-agent
.elastic-agent-standalone
fromelastic-agent
repo.runAsUser: 1000
and add required capabilities in k8s manifest (SYS_PTRACE and DAC_OVERRIDE) like following:Related issues
agentbeat
causes agent degradation elastic-agent#5269Screenshots
Current behaviour, without enough capabilities:
Behaviour after the changes and elastic/elastic-agent#5271: