Skip to content
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

feat(events): create access_remote_vm event #3551

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

AlonZivony
Copy link
Collaborator

@AlonZivony AlonZivony commented Oct 4, 2023

1. Explain what the PR does

An event for accessing the memory of a process externally (can be the same process) by the mem file of the process in procfs.

789bd69 test(events): add e2e test to access_remote_vm
fd6e01a feat(events): create access_remote_vm event
0854a88 feat(ebpf): support 7 arguments saving for kretprobe
491ba04 feat(events): add probe relevance attribute

Fix #3518

2. Explain how to test it

3. Other comments

@rafaeldtinoco
Copy link
Contributor

I loved the event! It LGTM, definitely.

There are just minor spell nits, some comments to be added to make it easier to understand your intents (if my interpretation is correct).

A small "point to clear" would be the VMA naming strategy/logic. I left a question for you there.

Also, If you could add a simple e2e-inst trigger for this type of event I would also appreciate (like we already spoke).

Nice work!

@AlonZivony AlonZivony force-pushed the feature/proc-mem-operations branch 2 times, most recently from 0ff94d2 to 3a5c024 Compare October 25, 2023 13:37
@rafaeldtinoco
Copy link
Contributor

I haven't seen a single test failing till now, so I am not sure to what you are referring. I can't really understand the problem without seeing it, so if you can reset the tests for me to see or send me a test suite that failed I will dig deeper.

Fix your pr.yaml file and force push. Wait for tests to finish and you will see. I dont need to reset anything on my side. Your pr.yaml is wrong.

@rafaeldtinoco
Copy link
Contributor

However, I don't see why should we have a sleep in the test like in the process tree. There is no state here to initialize. If there is a timing issue here, it is an issue with all e2e tests and should be fixed by the tests environment. However, I can add for now a sleep if you think it will solve it.

Never said it was a definitive answer. My feedback was "it might be related", but it might be an entire different thing. When you fix pr.yaml and tests fail you will be able to see. Let me know if you need a VM with the same images that are failing (but it might be intermittent among all of them, without considering v6.5 which always fails due to other reasoning).

@rafaeldtinoco
Copy link
Contributor

For the record:

https://gist.github.com/rafaeldtinoco/bb0bcf795fb2c821136db01417ca669a
https://gist.github.com/rafaeldtinoco/7042acfa78d3c7ca3f31ce8147d54255

Those files show the execution path in a 5.19 (event works) vs a 6.5 (event does not work).

rafaeldtinoco@rugged:mine$ gh gist create asyncio.perf.5.19.0-50-generic
- Creating gist asyncio.perf.5.19.0-50-generic
✓ Created secret gist asyncio.perf.5.19.0-50-generic
https://gist.github.com/rafaeldtinoco/bb0bcf795fb2c821136db01417ca669a

rafaeldtinoco@rugged:mine$ gh gist create asyncio.perf.6.5.9-arch2-1
- Creating gist asyncio.perf.6.5.9-arch2-1
✓ Created secret gist asyncio.perf.6.5.9-arch2-1
https://gist.github.com/rafaeldtinoco/7042acfa78d3c7ca3f31ce8147d54255

Im using https://gist.github.com/rafaeldtinoco/1e619d9d25a4a934b0ef577304125b87 to test.

@AlonZivony
Copy link
Collaborator Author

AlonZivony commented Nov 19, 2023

Alright, but be aware that there are many detections from this signature coming from regular processes (not sure your signature will filter for specific stuff, but systemd, dbus-daemon, etc are all being "detected").

Yea I am aware, but there is enough information in the event to filter regular stuff out.

Another thing, are you sure you want 1 event per VMA ? You may gets lots of events from the same action:

You are right that it might spam, but it is significant.
Each vma has its own name and own permissions, and you don't see operations on the file done frequently or in massive amount.
It might be a cause of malicious spam, but it is true for almost any event.

@AlonZivony
Copy link
Collaborator Author

Only pushed to see tests, still not fixed

@AlonZivony AlonZivony force-pushed the feature/proc-mem-operations branch 3 times, most recently from ee989e1 to 97963ff Compare November 28, 2023 10:01
@rafaeldtinoco
Copy link
Contributor

Looks like the tests failed but when looking at the output the event (at least on 4.18) worked. Needs some fine tuning I believe.

@AlonZivony
Copy link
Collaborator Author

You can see that the problem is the version check, because the remote_pid value is 0.
I will try to find another type.

@AlonZivony AlonZivony marked this pull request as draft November 29, 2023 10:16
@rafaeldtinoco rafaeldtinoco added security issues that could taint tracee and removed security issues that could taint tracee labels Nov 30, 2023
@AlonZivony AlonZivony force-pushed the feature/proc-mem-operations branch 3 times, most recently from bc33179 to 24d5e97 Compare January 2, 2024 21:20
AlonZivony and others added 4 commits January 3, 2024 02:13
Add to each probe the option to determine its relevance according to
the OS version.
If a probe is irrelevant, an attempt to load it won't be initiated.
This allows to have different probes for events according to OS
version.
The first 6 arguments are passed to functions using registers.
From the 7th forward, the arguments pass through the stack.
For this reason, only saving the first 6 arguments was supported
until now.
This commit add the 7th argument also to the saved args between
kprobe and kretprobe.
An event for accessing the memroy of a process externally (can be the
same process) by the mem file of the process in procfs.

Co-authored-by: OriGlassman <39296766+origlassman@users.noreply.github.com>
Add e2e test to check that the access_remote_vm works well.
@geyslan
Copy link
Member

geyslan commented Feb 21, 2024

We have this update #3875

Please rebase your PR against main to make use of the new workflow setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Writing to a process memory event
4 participants