Skip to content

Fix process tracking confusion, inadvertent proc table modification #236

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

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

hillu
Copy link
Collaborator

@hillu hillu commented Dec 14, 2024

For non-execve* syscalls, we consult the process table to find out whether we have seen the process before or whether a new entry needs to be added to the process table.

The process table lookup was done using .get_or_retrieve which might modify the process table by filling in a missing entry from /proc/$PID/ and subsequently returning a misleading result that contained only a process START_TIME instead of an EVENT_ID.

This problem would cause the event ID to be ignored and break process label inheritance, particularly in double-fork scenarios common in shell scripts. Since a race can't be avoided in accessing /proc, reproducing this bug was quite unreliable.

To fix this, we simply use .get_pid which will not modify the process table for its lookup.

For non-`execve*` syscalls, we consult the process table to find out
whether we have seen the process before or whether a new entry needs
to be added to the process table.

The process table lookup was done using `.get_or_retrieve` which might
modify the process table by filling in a missing entry from
`/proc/$PID/` and subsequently returning a misleading result that
contained only a process `START_TIME` instead of an `EVENT_ID`.

This problem would cause the event ID to be ignored and break process
label inheritance, particularly in double-`fork` scenarios common in
shell scripts. Since a race can't be avoided in accessing `/proc`,
reproducing this bug was quite unreliable.

To fix this, we simply use `.get_pid` which will not modify the
process table for its lookup.
@hillu hillu merged commit e1390bb into threathunters-io:master Dec 14, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant