-
Notifications
You must be signed in to change notification settings - Fork 42
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
[BUG] New os user/group doesn't reflect in Cloudbeat #235
[BUG] New os user/group doesn't reflect in Cloudbeat #235
Comments
I have prioritized this as a 0 @tehilashn the definition of done should be that remediations should show up as passing and there should be a test developed for this. |
Very thorough, Uri! This helped me while working on I managed to make those tests work by using directory mounts and some other hacks. The whole experiment with mounted files is also neatly described in this blog. I found that it's possible to run the
So this is for containerized cloudbeat, but what about Elastic Agent? We use the same mount format in those manifests, and I've confirmed that it mostly doesn't work when the file is changed on host. A newly created Agent pod comes online with the latest file contents/inode. Interestingly, in some cases it seems to work for the first time the file is changed after pod creation. The pod goes into a crash loop for a few seconds, and comes back with the latest file contents/inode. This only seems to happen once, and it seems important to understand why.
Do you mean making changes to the customer's host? I think this goes one step beyond anything we're doing currently, but I wonder if any other use case of Agent/beats does this. A host-agnostic script that runs on Elastic Agent startup could do the trick. @DaveSys911? |
Some clarification: for files that are mounted individually (ie not as part of a directory tree), our file system fetcher works just fine for updates that are made in place. The problem only occurs with tools like
This can be verified for example with the
The change will be reflected in the mounted file on the container. The same problem with the mounted file would happen with a mounted directory if we replace it with a new directory of the same name. But making changes to a directory subtree is analogous to making changes to a mounted file in place as described, so it works. It follows that if we don't mount the directory, or don't somehow re-mount the mounted file, changes made by
The options I can see:
|
Thanks @yashtewari . The ideal behaviour imo is for the user not to perform any manual operation. So option 2. seems like the best one. The question is - did you think of a way to implement it? what are the unknowns here/risks? |
@tehilashn no, it's mostly conceptual. A re-mount will definitely work, but you need superuser permissions to do mount operations, which we can't give to the Agent. |
This is interesting to me. Pure speculation, but with the file that is mounted being "deleted" (replaced), maybe we can expect the Agent to eventually restart itself? Looking into this. |
I am not sure that agent restart will solve it. |
@amirbenun yeah anything that triggers the file to be mounted again works, because the mount command considers the file path on the host. Once it is mounted, it gets tied to the inode. That's what I meant by "Agent restart": Agent pod restart. Delete the pod, delete the daemonset, remove the whole daemonset from the cluster and re-apply it. All of these work. |
Interesting, do you have some idea in mind on how to trigger such a restart based on a change? |
@amirbenun We can set up a watcher for inode changes and restart the pod if it's detected but two issues with this:
|
You're right @DaveSys911, the inode (and consequently the file contents of the mounted file) doesn't change from the perspective of the Agent, unless we mount the parent directory |
Looks like the auditbeat DaemonSet is already mounting all of |
Interesting, I didn't know we were mounting all |
Well I guess that for Auditbeat to work this is required. But auditbeat is unique, this is why we only have it for this specific Beat and not for Filebeat, Metricbeat etc. In Agent era, I'm not sure how we can avoid defining a superset of permissions and mounts. Maybe you can consider having it commented out and only users that actually require it should add it. But it has to do with the user experience we want to provide here. We had similar conversations at elastic/elastic-agent#381 (comment). @gizas feel free to comment here. |
since it requires upgrading the policies repo and we are too close to the last QA cycle, let's move it to 8.5 |
@oren-zohar , @tehilashn is this going to be part of 8.5? if not, can we move it? |
Thanks @ChrsMark for linking to the earlier discussion! For the purpose of mounting the
As before, in this case too files and directories in
Without this change, there are cases where the user would have to restart the Agent pods in order to see their changes reflected on their Kibana dashboard, and until they do so, the dashboard indication would be outdated/incorrect.
The user can view and edit the files and directories being mounted from the node to the Agent in the DaemonSet manifest that they obtain from Kibana.
I've opened an issue for this.
This is another use-case for features that will enable dynamic least privileges for our integrations. |
need to update other manifests before closing |
verified through checking automated tests report https://github.com/elastic/cloudbeat/commits/0d31ac7352706eaadbded5da4f270e8eac701884 - fixed |
Describe the bug
Remediation that requires creating a new OS user/group won't be presented to the user even though it took effect.
Preconditions
A Containerized cloudbeat using a Kind cluster.
To Reproduce
groupadd etcd
useradd -g etcd etcd
chown etcd:etcd /var/lib/etcd/
Expected behavior
CIS rule 1.1.12 is should pass as we apply the right remediation.
Investigation conclusions
/etc/group
&/etc/passwd
respectively.useradd
/groupadd
commands.As a result, the files inside the container are not synced.
Proposed solution
Mounting an entire directory will solve the issue because the directory's pointer to the inode gets updated.
Having said that, we don't want to mount the entire
etc
directory, therefore, we can create a new folder to mount and symlink the mentioned files.Screenshots
useradd
cmd modify/etc/passwd
file inode.Related issue:
The text was updated successfully, but these errors were encountered: