-
Notifications
You must be signed in to change notification settings - Fork 165
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] libs do not update proc.name
for renamed threads
#1011
Comments
@therealbobo @falcosecurity/libs-maintainers WDYT? 🤔 |
In my opinion the problem is that |
My point is that if it can change during the execution, rules authors can't rely on (otherwise, it can lead to bypasses). Moreover, we also have another field, |
I strongly believe that updating the process name is not what we need here. This is because many rules rely on |
I think the proc.name should remain consistent and shouldn't contains the thread info. It would be helpful having another field containing the thread information without updating the proc.name field which is strongly used in detection and falco rules. This is also causing a lot of noise cause often the field proc.name is used in whitelist. |
If the only way to change the process comm is via prctl, then IMO we should track the changes. (the "if" comes from the fact that you can easily overwrite argv[0] from userspace, but IIRC it's entirely separate from comm which lives in the kernel so it should be fine). AIUI, the confusion comes from all the different things that could be considered the name of a process (and I believe we expose at least most of them one way or another):
Since the comments appearing while I'm typing this indicate we don't want proc.name to contain updated comm, how about we introduce proc.comm for this? But in any case, if there isn't a spec for what fields contain what, let's make one and stick to it (it seems important for proc.name in particular since it implies "the" name while there isn't one). As much as Falco has become the main user of the libs, security isn't the only use case, we can also use the comm (updated by a legit process) to troubleshoot specific processes/threads by name, e.g. in OSS Sysdig |
Possible problem/question:
Now consider this:
wdyt? |
I think that |
This should not be ok if we want an immutable Anyway, I believe the root cause depends on the usage of Thus, why not use the executable name instead? 🤔 |
It all boils down to the question: what exactly is |
My TL;DR is: I believe rules authors want But I believe we have to reach consensus before introducing such changes. |
Hey 👋, happy to join the discussion.
Hence we may not need Rather we should prioritize getting the true In summary, getting technical clarity and feature completeness would be amazing as it's such an important aspect for threat detection:
|
Good point. I thought those definitions used command name (which in my mind is After your comment, I've changed my mind, and I'm not sure anymore that introducing
In the long term, we have to fix the symlink problem, but it's another issue. |
@leogr fully agree with touching up the docs a bit more and set expectations even better. Re true executable path and symlinks yes we will work on it and hopefully soon have a trustworthy Lastly, worthwhile mentioning is that Let's dig through the |
Over the past few weeks, I have talked to everyone about this problem, and I am now totally convinced that the solution is:
So, IMO the next step would be to review the field documentation. |
If you all agree, I could try to help with te documentation! 😄 |
Yes please 🙏 |
This is all addressed, not just documentation wise but @therealbobo also added #1015 |
Uhm just reading again this issue I've noticed this is not completely fixed, in #1015 we added the kernel code to manage |
oh yes we need to fix this, thanks for checking again @Andreagit97! |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
@therealbobo and @Andreagit97 just checking in where we are at for this issue? What still needs to be done? Could we add a new summary of open items? |
Uhm this comment #1011 (comment) should be still valid, AFAIK nothing has been changed 🤔 |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Describe the bug
The Falco libs use the
/proc
filesystem to retrieve information about processes when they start up. However, if a thread, during its lifecycle, changes its name using aprctl
system call, theproc.name
value is not updated. This means that Falco may not be able to accurately identify the process and could lead to errors or security issues.In the following situation Falco doesn't take into account the renaming because it's only aware of the information of the process at its creation.
On the contrary, in the following situation, given that the renaming has already taken place before Falco has started, Falco will display correctly the
proc.name
.How to reproduce it
If we consider the first situation shown above:
gcc worker.c -o worker
):worker
program compiled in first stepproc.name
If we consider the second situation shown above:
gcc worker.c -o worker
):worker
program compiled in the previous stepproc.name
At the end the concept is simple: if Falco starts before the renaming, it will only use the information available at the start of the process; otherwise if Falco starts after the renaming, it will have the complete information and use the effective thread name.
Expected behaviour
Given that
proc.name
is the name (excluding the path) of the executable generating the event.When a thread changes its name within a process, Falco should update the
proc.name
value to reflect the new thread name. This should happen regardless of whether Falco was started before or after the thread was renamed. This will ensure that Falco is correctly identifying the process and can take appropriate actions as needed.Screenshots
Here's how Falco behaves if it starts before the matching process (first situation).
Here's how Falco behaves if it starts after (second situation) the matching process and before the actual read (so when the process has already changed its name).
Here's the output of the
ps
command after the renaming:Environment
DEB
Additional context
I think that the problem is linked to the fact that a thread is added to the thread table via
parse_clone_exit
libs/userspace/libsinsp/parsers.cpp
Line 1653 in 9096f42
In this way, when a
prctl
occurs, the threadcomm
is never updated. A possible solution could be to hook theprctl
and update the thread table accordingly.The text was updated successfully, but these errors were encountered: