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

Enable seccomp for zhm #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

bbarenblat
Copy link

Currently, zhm runs as root and handles network traffic; any sandboxing we can get at all is a positive development. This PR implements a basic seccomp-bpf filter for zhm using libseccomp. The filter still allows a lot of potentially dangerous operations (e.g., unlink(2)), but it does block stuff like ptrace(2), so it’s a definite improvement over nothing at all.

The filter is based partly on a close reading of the zhm and libhesiod source code and partly on empirical evidence from running zhm under strace(1). I’ve run zhm with this filter for several days without incident, but some edge cases (e.g., server failover) are still untested.

This PR also enables seccomp in Debian builds, which breaks building on kFreeBSD, but Zephyr didn’t build there anyway to begin with, so I don’t feel too bad about it. In any case, it shouldn’t be too hard to conditionalize the libseccomp-dev dependency on being on Linux; I didn’t do it here because it’s simpler this way.

Prevent zhm from doing some evil things while it runs (e.g., ptracing)
by implementing a basic seccomp-bpf filter. The filter still allows a
lot of potentially dangerous operations (e.g., unlink(2)), but this is
a good start.

The filter is based partly on a close reading of the zhm and libhesiod
source code and partly on empirical evidence from running zhm under
strace. I’ve run zhm with this filter for several days without
incident, but some edge cases (e.g., server failover) are still
untested.

configure decides whether or not to enable seccomp by looking for
libseccomp. By default, it treats seccomp as an enhancement and enables
it opportunistically. Builders can force seccomp to be enabled or
disabled by passing --with-seccomp or --without-seccomp, respectively,
to configure.
Commit 22a59d2 added basic seccomp
support to zhm. Since zhm currently runs as root and handles network
traffic, any sandboxing we can get is a good idea. Take a dependency
on libseccomp-dev and enable seccomp support for zhm. This breaks
building on kFreeBSD, but this package doesn’t currently build there
anyway, so it’s not making things any worse.
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