-
Notifications
You must be signed in to change notification settings - Fork 240
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
Implement capability dropping and document needed capabilities #231
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bobrik
force-pushed
the
ivan/capabilities
branch
3 times, most recently
from
July 6, 2023 04:58
03da5da
to
9948b38
Compare
bobrik
commented
Jul 6, 2023
go.mod
Outdated
) | ||
|
||
replace github.com/aquasecurity/libbpfgo => github.com/bobrik/libbpfgo v0.0.0-20230704220959-d2cc6f8a97da |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bobrik
force-pushed
the
ivan/capabilities
branch
from
July 19, 2023 04:44
9948b38
to
ca3b87c
Compare
With socket activation and the following hardened service config I was able to make [Unit]
Requires=ebpf_exporter.socket
[Service]
ExecStart=/ebpf_exporter --config.dir=/examples --config.names=timers --web.listen-address=fd://0 --capabilities.keep=cap_syslog
RootDirectory=/opt/ebpf_exporter
RestrictAddressFamilies=yes
RestrictNamespaces=yes
DynamicUser=true
# This might be needed to prevent Go from using setrlimit:
# * https://github.com/golang/go/blob/go1.20.6/src/syscall/rlimit.go#L18-L40
LimitNOFILE=1024
PrivateDevices=yes
PrivateNetwork=yes
# Breaks capabilities
# PrivateUsers=yes
ProtectClock=yes
# Needed to resolve symbols (removes CAP_SYSLOG)
# ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectHostname=yes
# Needed to resolve symbols
# ProtectKernelTunables=yes
ProtectHome=yes
ProtectProc=noaccess
# Needed to resolve symbols
# ProcSubset=pid
# Needed to resolve symbols
# ProcSubset=pid
SystemCallArchitectures=native
LockPersonality=yes
MemoryDenyWriteExecute=yes
RestrictRealtime=yes
UMask=0077
IPAddressDeny=any
# SystemCallFilter are probably useless, but they keep systemd-analyze happy
SystemCallFilter=~@clock
SystemCallFilter=~@cpu-emulation
# @debug includes perf_event_open, which is needed for kprobes and uprobes:
# * https://github.com/libbpf/libbpf/blob/v1.2.0/src/libbpf.c#L10047
# SystemCallFilter=~@debug
SystemCallFilter=~@module
SystemCallFilter=~@mount
SystemCallFilter=~@obsolete
SystemCallFilter=~@raw-io
SystemCallFilter=~@reboot
SystemCallFilter=~@resources
SystemCallFilter=~@swap
# Needed for bpf()
# SystemCallFilter=~@privileged
AmbientCapabilities=CAP_BPF CAP_PERFMON CAP_SYSLOG
CapabilityBoundingSet=CAP_BPF CAP_PERFMON CAP_SYSLOG It keeps
|
bobrik
force-pushed
the
ivan/capabilities
branch
from
July 20, 2023 04:41
ca3b87c
to
02f2bb4
Compare
bobrik
force-pushed
the
ivan/capabilities
branch
from
July 25, 2023 04:05
02f2bb4
to
380912c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.