Skip to content

Commit 9b4e863

Browse files
committed
fix(helm): default to the documented capability set instead of privileged (edgecomllc#665)
The chart ran the container as privileged: true by default and documented the capability set NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON as an alternative. The capability set is what the data plane uses: BPF and PERFMON to load and attach programs, NET_ADMIN for XDP and routes, SYS_RESOURCE for RLIMIT_MEMLOCK, SYS_ADMIN for the bpffs and debugfs mounts in the entrypoint. A privileged container is every capability, no device cgroup, unmasked /proc and /sys and no seccomp or AppArmor profile. The capability set is the default now, with privileged: true as the documented fallback for the environments that deny the mounts anyway: an AppArmor profile that forbids mount (the runtime's default on Ubuntu and Debian, which appArmorProfile Unconfined lifts), a seccomp profile that blocks mount or bpf, or a runtime that rejects BPF and PERFMON on a kernel before 5.8. README and NOTES say so. Verified on a three-node kind cluster: the pod starts, the mounts succeed, the UPF serves, and it survives scaling and a node drain. Trivy's config scan flags SYS_ADMIN (KSV-0005); the rule joins .trivyignore with the reason, next to KSV-0118, whose comment is updated. Signed-off-by: Martin Matyas <[email protected]>
1 parent a84239a commit 9b4e863

4 files changed

Lines changed: 31 additions & 12 deletions

File tree

‎.deploy/helm/eupf/README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ The default values produce a working pod: eUPF is configured via `UPF_*` environ
1919
kubelet --allowed-unsafe-sysctls 'net.ipv4.ip_forward'
2020
```
2121

22-
- **Privileges**: eUPF loads eBPF programs, mounts bpffs/debugfs (via the image entrypoint) and raises `RLIMIT_MEMLOCK`. By default the chart runs the container as `privileged: true`. If your environment allows a finer-grained setup, override `securityContext`, e.g.:
22+
- **Privileges**: eUPF loads eBPF programs, mounts bpffs/debugfs (via the image entrypoint) and raises `RLIMIT_MEMLOCK`. By default the chart gives the container the capabilities this takes and nothing more:
2323

2424
```yaml
2525
securityContext:
2626
capabilities:
2727
add: [NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON]
2828
```
2929
30+
The container keeps the device cgroup, the masked `/proc` and `/sys` paths and the runtime's seccomp and AppArmor profiles. Some environments deny the entrypoint's mounts even with `SYS_ADMIN`: nodes whose AppArmor profile forbids `mount` (the runtime's default profile on Ubuntu and Debian does), a custom seccomp profile that blocks `mount` or `bpf`, or a runtime that rejects `BPF` and `PERFMON` on a kernel before 5.8. There, either allow the mounts (for AppArmor: `securityContext.appArmorProfile: {type: Unconfined}` on Kubernetes 1.30+, the `container.apparmor.security.beta.kubernetes.io/eupf: unconfined` pod annotation before) or fall back to a privileged container:
31+
32+
```yaml
33+
securityContext:
34+
privileged: true
35+
```
36+
3037
- The `/sys` hostPath is mounted read-only into the pod (required by the entrypoint to mount bpffs/debugfs).
3138

3239
## Configuration

‎.deploy/helm/eupf/templates/NOTES.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ eUPF is configured via a ConfigMap (config.enabled=true), mounted at
2424
Notes:
2525
- Nodes must allow the unsafe sysctl net.ipv4.ip_forward
2626
(kubelet --allowed-unsafe-sysctls='net.ipv4.ip_forward').
27-
- The container runs privileged by default (eBPF data plane requires it);
28-
see the chart README for a capabilities-based alternative.
27+
- The container runs with the capabilities the eBPF data plane needs
28+
(NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON), not privileged; see the
29+
chart README for the environments that need the privileged fallback.
2930
- The REST API is served on port {{ .Values.service.port }} (service port "http").

‎.deploy/helm/eupf/values.yaml‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,18 @@ podSecurityContext:
223223
- name: net.ipv4.ip_forward
224224
value: "1"
225225

226-
# eUPF loads eBPF programs, mounts bpffs/debugfs and raises RLIMIT_MEMLOCK,
227-
# which requires elevated privileges. If your environment allows it, a more
228-
# fine-grained alternative is:
229-
# capabilities:
230-
# add: [NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON]
226+
# eUPF loads eBPF programs (BPF, PERFMON), attaches XDP and sets routes
227+
# (NET_ADMIN), raises RLIMIT_MEMLOCK (SYS_RESOURCE) and mounts bpffs/debugfs
228+
# from the image entrypoint (SYS_ADMIN). These capabilities are all it needs;
229+
# the container keeps the device cgroup, the masked /proc and /sys paths and
230+
# the runtime's seccomp and AppArmor profiles. Where the mounts are denied
231+
# anyway (an AppArmor profile that forbids mount, a seccomp profile that
232+
# blocks mount or bpf, a runtime that does not know CAP_BPF on a kernel
233+
# before 5.8), fall back to a privileged container:
234+
# privileged: true
231235
securityContext:
232-
privileged: true
236+
capabilities:
237+
add: [NET_ADMIN, SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON]
233238

234239
extraContainerPorts:
235240
- name: metrics

‎.trivyignore‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@ AVD-KSV-0030
1616
AVD-KSV-0106
1717
AVD-KSV-0117
1818

19-
# eUPF data plane requires a privileged (root) container to load eBPF
20-
# programs, mount bpffs/debugfs and raise RLIMIT_MEMLOCK - running with
21-
# a restricted security context is not supported by design.
19+
# The eUPF data plane runs as root with the capabilities it needs (NET_ADMIN,
20+
# SYS_ADMIN, SYS_RESOURCE, BPF, PERFMON) to load eBPF programs, mount
21+
# bpffs/debugfs and raise RLIMIT_MEMLOCK - a restricted security context is
22+
# not supported by design.
2223
AVD-KSV-0118
2324

25+
# SYS_ADMIN is what the image entrypoint mounts bpffs and debugfs with; the
26+
# other capabilities are a smaller grant than the privileged container the
27+
# chart ran before, which had every capability and no runtime profile.
28+
AVD-KSV-0005
29+
2430
# The eUPF data plane needs a read-only /sys hostPath mount: the image
2531
# entrypoint mounts bpffs and debugfs under /sys to load the eBPF
2632
# programs. A "disallowed volume type" (hostPath) is by design here.

0 commit comments

Comments
 (0)