fix: ancestors and parent_exe for zombie process #141
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For zombie processes
ancestors
andparent_exe
were not the "real" ones.The purpose of making a zombie process is making difficult to track the real parent/child relationship. However in kunai we have the data to recover the real parent/child relationships across the full chains of ancestors of a given process.
Prior to this PR: kunai is computing
ancestors
andparent_exe
from theparent_task
returned by the kernel. The drawback with this approach is that when the process becomes a zombie the kernel setsparent
to init process and we lose track of the real origin of the process.This PR addresses this issue and puts the real
ancestors
and realparent_exe
in events' fieldsUsing real
ancestors
andparent_exe
introduces some inconsistencies in the events. After the fix.info.parent_task
section does not show relevant information as it contains task information collected in kernel. So, this needs to be addressed too to reflect real parent task.Finally, when replacing
.info.parent_task
with the real parent information completely hides the fact the task is a zombie, simply because we fixed everything up to resolve zombification. This is not desired as zombie tasks are not so frequent under regular circumstances but often used by malware. So we propose to add a.info.task.zombie
and.info.parent_task.zombie
fields (booleans) to show when a task or its parent is a zombie process.To sum up this PR addresses:
.data.ancestors
field.data.parent_exe
forexecve
andexecve_script
events.info.parent_task
to be the real parent task.info.task.zombie
and.info.parent_task.zombie
boolean flags to identify when a task is a zombie