From fc71a58a283aaf096d3472c9f5b4b19c08bc8116 Mon Sep 17 00:00:00 2001 From: Ricardo Branco Date: Tue, 1 Dec 2026 11:33:31 +0100 Subject: [PATCH 1/2] seccomp: fix arg_cnt for socket() allow rules Both socket() rules passed two comparators but set arg_cnt to 1, so libseccomp ignored the second one. As a result any AF_UNIX socket type and any AF_NETLINK protocol were allowed, instead of only SOCK_STREAM UNIX sockets and NETLINK_KOBJECT_UEVENT netlink sockets. Set arg_cnt to 2 so both comparators are applied. Fixes: #707 Signed-off-by: Ricardo Branco --- src/Daemon/Seccomp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Daemon/Seccomp.c b/src/Daemon/Seccomp.c index 08e90b0b..6f7af6c1 100644 --- a/src/Daemon/Seccomp.c +++ b/src/Daemon/Seccomp.c @@ -105,11 +105,11 @@ bool setupSeccompWhitelist(void) ret |= seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket), - 1, + 2, SCMP_A0(SCMP_CMP_EQ, PF_LOCAL), SCMP_A1(SCMP_CMP_MASKED_EQ, SOCK_STREAM, SOCK_STREAM)); ret |= seccomp_rule_add( - ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket), 1, SCMP_A0(SCMP_CMP_EQ, PF_NETLINK), SCMP_A2(SCMP_CMP_EQ, NETLINK_KOBJECT_UEVENT)); + ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket), 2, SCMP_A0(SCMP_CMP_EQ, PF_NETLINK), SCMP_A2(SCMP_CMP_EQ, NETLINK_KOBJECT_UEVENT)); ret |= seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(bind), 0); ret |= seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(accept), 0); ret |= seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(listen), 0); From a7015ade091ed783b217c3ceb8c41435c63a1f26 Mon Sep 17 00:00:00 2001 From: Ricardo Branco Date: Tue, 1 Dec 2026 11:34:22 +0100 Subject: [PATCH 2/2] seccomp: only allow SOCK_STREAM for AF_UNIX sockets The previous mask of SOCK_STREAM (1) only tested bit 0 of the type argument, so SOCK_SEQPACKET (5) and SOCK_RAW (3) also matched. Mask out SOCK_CLOEXEC and SOCK_NONBLOCK and require the remaining type to be exactly SOCK_STREAM. The mask is 32-bit since the kernel only looks at the lower 32 bits of the int argument. Signed-off-by: Ricardo Branco --- src/Daemon/Seccomp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Daemon/Seccomp.c b/src/Daemon/Seccomp.c index 6f7af6c1..d160036e 100644 --- a/src/Daemon/Seccomp.c +++ b/src/Daemon/Seccomp.c @@ -107,7 +107,8 @@ bool setupSeccompWhitelist(void) SCMP_SYS(socket), 2, SCMP_A0(SCMP_CMP_EQ, PF_LOCAL), - SCMP_A1(SCMP_CMP_MASKED_EQ, SOCK_STREAM, SOCK_STREAM)); + /* SOCK_STREAM only, ignoring the SOCK_CLOEXEC and SOCK_NONBLOCK flags */ + SCMP_A1(SCMP_CMP_MASKED_EQ, (uint32_t)~(SOCK_CLOEXEC | SOCK_NONBLOCK), SOCK_STREAM)); ret |= seccomp_rule_add( ctx, SCMP_ACT_ALLOW, SCMP_SYS(socket), 2, SCMP_A0(SCMP_CMP_EQ, PF_NETLINK), SCMP_A2(SCMP_CMP_EQ, NETLINK_KOBJECT_UEVENT)); ret |= seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(bind), 0);