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

Run with least permissions in Linux #91

Closed
mariomac opened this issue May 4, 2023 · 3 comments
Closed

Run with least permissions in Linux #91

mariomac opened this issue May 4, 2023 · 3 comments
Assignees

Comments

@mariomac
Copy link
Contributor

mariomac commented May 4, 2023

Basically, investigate and document which capabilities are needed to run the executable without requiring full privileged mode. Provide some examples for e.g. Docker and Kubernetes deployments.

@mariomac mariomac self-assigned this May 4, 2023
@mariomac
Copy link
Contributor Author

mariomac commented May 4, 2023

You can replace full privileges by individual capabilities, but it requires mounting the shared maps in the filesystem, as far as I see, only the already overloaded CAP_SYS_ADMIN have the rights for mounting.

It might be slightly safer than full privileges but definitely I would have preferred to restrict the requirements to CAP_PTRACE, CAP_BPF and few more capabilities.

@mariomac
Copy link
Contributor Author

mariomac commented May 5, 2023

I've been investigating by manually running the otelauto process and manually assigning the capabilities and it still requires the CAP_SYS_ADMIN capability to pin the BPF maps. Even premounting the /sys/fs/bpf and giving total access to the nonprivileged users, the library complains when loading/pinning the maps.

I tried later by using unpinned maps, but I still get a different error that only goes off when setting the CAP_SYS_ADMIN:

setting uprobe: creating perf_uprobe PMU: token /proc/2388/exe:0x2b61a0: opening perf event: permission denied" function=net/http.HandlerFunc.ServeHTTP

I tried with the following capabilities (many of them aren't needed, just trial-and-error) and only adding cap_sys_admin solves the issue:

cap_sys_resource,cap_dac_override,cap_bpf,cap_perfmon,cap_net_admin,cap_fowner,cap_dac_read_search

@mariomac
Copy link
Contributor Author

mariomac commented May 5, 2023

Closing, but at some point we could reopen it if future versions of the kernel increases granularity of capabilities.

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

No branches or pull requests

1 participant