diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2022-12-01 14:06:37 +0100 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2022-12-01 14:06:37 +0100 |
commit | 57b229012a5b5ff97889ae44c9b6fa77ba9b3a5c (patch) | |
tree | 72d3b1b0fc572912143b4abd84b34410a9e09629 | |
parent | 5fd603ce60e3d7afcb55bd042374b77d50b0453f (diff) | |
download | docker-57b229012a5b5ff97889ae44c9b6fa77ba9b3a5c.tar.gz |
seccomp: block socket calls to AF_VSOCK in default profile
This syncs the seccomp-profile with the latest changes in containerd's
profile, applying the same changes as https://github.com/containerd/containerd/commit/17a93240359b406c78e5f08a20013f759ea230bf
Some background from the associated ticket:
> We want to use vsock for guest-host communication on KubeVirt
> (https://github.com/kubevirt/kubevirt). In KubeVirt we run VMs in pods.
>
> However since anyone can just connect from any pod to any VM with the
> default seccomp settings, we cannot limit connection attempts to our
> privileged node-agent.
>
> ### Describe the solution you'd like
> We want to deny the `socket` syscall for the `AF_VSOCK` family by default.
>
> I see in [1] and [2] that AF_VSOCK was actually already blocked for some
> time, but that got reverted since some architectures support the `socketcall`
> syscall which can't be restricted properly. However we are mostly interested
> in `arm64` and `amd64` where limiting `socket` would probably be enough.
>
> ### Additional context
> I know that in theory we could use our own seccomp profiles, but we would want
> to provide security for as many users as possible which use KubeVirt, and there
> it would be very helpful if this protection could be added by being part of the
> DefaultRuntime profile to easily ensure that it is active for all pods [3].
>
> Impact on existing workloads: It is unlikely that this will disturb any existing
> workload, becuase VSOCK is almost exclusively used for host-guest commmunication.
> However if someone would still use it: Privileged pods would still be able to
> use `socket` for `AF_VSOCK`, custom seccomp policies could be applied too.
> Further it was already blocked for quite some time and the blockade got lifted
> due to reasons not related to AF_VSOCK.
>
> The PR in KubeVirt which adds VSOCK support for additional context: [4]
>
> [1]: https://github.com/moby/moby/pull/29076#commitcomment-21831387
> [2]: https://github.com/moby/moby/commit/dcf2632945b87acedeea989a5aa36c084a20ae88
> [3]: https://kubernetes.io/docs/tutorials/security/seccomp/#enable-the-use-of-runtimedefault-as-the-default-seccomp-profile-for-all-workloads
> [4]: https://github.com/kubevirt/kubevirt/pull/8546
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
-rw-r--r-- | profiles/seccomp/default.json | 14 | ||||
-rw-r--r-- | profiles/seccomp/default_linux.go | 14 |
2 files changed, 26 insertions, 2 deletions
diff --git a/profiles/seccomp/default.json b/profiles/seccomp/default.json index 921b2bd3fe..f361066a2f 100644 --- a/profiles/seccomp/default.json +++ b/profiles/seccomp/default.json @@ -356,7 +356,6 @@ "signalfd4", "sigprocmask", "sigreturn", - "socket", "socketcall", "socketpair", "splice", @@ -422,6 +421,19 @@ }, { "names": [ + "socket" + ], + "action": "SCMP_ACT_ALLOW", + "args": [ + { + "index": 0, + "value": 40, + "op": "SCMP_CMP_NE" + } + ] + }, + { + "names": [ "personality" ], "action": "SCMP_ACT_ALLOW", diff --git a/profiles/seccomp/default_linux.go b/profiles/seccomp/default_linux.go index 775ab275d6..1ee7d7a808 100644 --- a/profiles/seccomp/default_linux.go +++ b/profiles/seccomp/default_linux.go @@ -348,7 +348,6 @@ func DefaultProfile() *Seccomp { "signalfd4", "sigprocmask", "sigreturn", - "socket", "socketcall", "socketpair", "splice", @@ -417,6 +416,19 @@ func DefaultProfile() *Seccomp { }, { LinuxSyscall: specs.LinuxSyscall{ + Names: []string{"socket"}, + Action: specs.ActAllow, + Args: []specs.LinuxSeccompArg{ + { + Index: 0, + Value: unix.AF_VSOCK, + Op: specs.OpNotEqual, + }, + }, + }, + }, + { + LinuxSyscall: specs.LinuxSyscall{ Names: []string{"personality"}, Action: specs.ActAllow, Args: []specs.LinuxSeccompArg{ |