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

Q: intercept syscalls from same process #325

Closed
ghost opened this issue May 19, 2021 · 3 comments
Closed

Q: intercept syscalls from same process #325

ghost opened this issue May 19, 2021 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented May 19, 2021

I'm working on a sandbox on Linux, what I want to achieve is to intercept syscalls and return emulated value or change registers/pointers and execute the syscall with modified value.

I would like to achieve this from the same process, my code is already injected into the target process during startup.

Is it possible to do with seccomp?
If you have some example would be helpful or any other recommendations, maybe there is a better way to achieve same

@pcmoore pcmoore changed the title Intercept syscalls Q: intercept syscalls from same process May 19, 2021
@pcmoore
Copy link
Member

pcmoore commented May 19, 2021

It is probably worth mentioning that attempting to intercept syscalls as a form of sandboxing from within the same address space as the process being sandboxed is going to be prone to failure. A malicious application could find a way to detect that it is being sandboxed and take action against the sandboxing code running in its address space.

A better option would be to go with a more traditional static syscall filter as is done by a large number of sandboxing tools or create a supervisor process to monitor and intercept syscalls using the notification capabilities added to seccomp/libseccomp.

@ghost
Copy link
Author

ghost commented May 19, 2021

I'm pretty new to seccomp, day before even didn't knew about it's existence, if I understood correctly recent addition of notifications gives us ability to handle syscalls from usermode.
Do you have a code I can use as a reference for this task (seccomp notif. to intercept syscalls) ?

@pcmoore
Copy link
Member

pcmoore commented May 20, 2021

You could always check the test below, it's rather simple but it should give you a basic idea on how to use it:

I'm going to close this issue as I think the question has been resolved, but if you disagree feel free to reopen/comment.

@pcmoore pcmoore closed this as completed May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant