Repository navigation
seccomp: Explicitly block socketcall to prevent AF_ALG filter bypass - #21
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the default seccomp profile against AF_ALG socket filtering bypasses on architectures that still support the legacy socketcall(2) multiplexer, by explicitly denying socketcall rather than implicitly relying on it not being in the allow-list.
Changes:
- Remove
socketcallfrom the unconditional allow-list in the default seccomp profile. - Add an explicit
SCMP_ACT_ERRNOrule denyingsocketcallto prevent bypassing thesocket(2)address-family arg filters. - Regenerate
seccomp/default.jsonto reflect the updated Go profile.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| seccomp/default_linux.go | Removes socketcall from the allow-list and adds an explicit deny rule with rationale comments. |
| seccomp/default.json | Updates the generated default profile JSON to include an explicit deny rule for socketcall. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7e5db0e to
962afae
Compare
|
notes from "claude my eyes right out": PR #21 (updated) — complete analysis What the PR does: Removes errnoRet := uint(unix.EPERM) // = 1
// ...
{
LinuxSyscall: specs.LinuxSyscall{
Names: []string{"socketcall"},
Action: specs.ActErrno,
ErrnoRet: &errnoRet, // EPERM = 1
},
},
// ... three-range socket ALLOW rules followThe update moved the socketcall deny rule to before the socket ALLOW rules in the Go slice. The The ordering change makes no difference. The BPF for both orderings is byte-for-byte identical (confirmed empirically). libseccomp sorts rules internally and generates the same BPF regardless of insertion order for this case. Why the bypass still works — the two-layer failure: Layer 1 — runc silently drops the deny rule. runc's Layer 2 — even if runc didn't discard it, libseccomp ignores it too. When a rule's action equals the filter default action, libseccomp's BPF generator produces identical output with or without the rule — confirmed: cases A and B generate byte-identical BPF. The surviving auto-generated bypass path. libseccomp automatically adds a
What actually fixes it: Use any errno value other than
|
a3e5276 to
29d0500
Compare
The socket arg filters that block AF_ALG and AF_VSOCK only apply to the direct socket(2) syscall. On architectures with the legacy socketcall(2) multiplexer (i386, s390, MIPS o32), libseccomp auto-generates a socketcall(SYS_SOCKET) -> ALLOW companion for each socket ALLOW rule. This companion only checks the socketcall sub-command number, not the address family (behind a pointer BPF cannot dereference), bypassing the AF_ALG block for 32-bit binaries. Add an explicit socketcall -> ERRNO(ENOSYS) deny rule placed before the socket allow rules. ENOSYS must be used instead of EPERM because the deny errno must differ from DefaultErrnoRet (EPERM): runc skips calling seccomp_rule_add() entirely when a rule's action matches the default action, so an EPERM deny is never passed to libseccomp and the auto-generated socketcall ALLOW path survives unchallenged. With ENOSYS, runc passes the rule through, and libseccomp replaces the auto-generated ALLOW path with ERRNO(ENOSYS) in the BPF. Since Linux 4.3, all affected architectures provide direct socket syscalls and modern glibc/musl already use them. Only very old statically-linked 32-bit binaries compiled against pre-4.3 glibc would be affected. Co-authored-by: Tianon Gravi <admwiggin@gmail.com> Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Our Linux CI and release jobs execute on GitHub Actions runners, and in our "build-docker" job we use Docker containers to build a set of release binaries for multiple Linux distributions and versions. Per actions/runner-images#14748, GitHub Actions are now migrating their "ubuntu-latest" runners from the Ubuntu 24.04 ("Noble Numbat") Long-Term Support (LTS) release to the Ubuntu 26.04 ("Resolute Raccoon") LTS release. At present, the former release provides version 28.0.4 of Docker by default, while the latter provides Docker version 29.4.2: https://github.com/actions/runner-images/blob/releases/ubuntu24/20261012/images/ubuntu/Ubuntu2404-Readme.md#tools https://github.com/actions/runner-images/blob/releases/ubuntu26/20261012/images/ubuntu/Ubuntu2604-Readme.md#tools However, as described in actions/runner-images#14790, Docker v29.4.2 effectively disables network access in older 32-bit Linux containers such as the ones we build using Debian 11 and Debian 12. As a result, our CI and release workflows' "build-docker" jobs will fail on "ubuntu-26.04" runners until the version of Docker provided in those runners has been updated to at least 29.4.3. To ensure our CI and release workflows continue to pass, we therefore temporarily pin our "build-docker" jobs to "ubuntu-24.04" runners. (Note that this mirrors the explicit Ubuntu version already specified for our "build-docker-arm" jobs.) Once the issue reported in actions/runner-images#14790 has been addressed, we can update our "build-docker" jobs to again use "ubuntu-latest" runners. At the same time, we expect to also update our "build-docker-arm" jobs to use "ubuntu-26.04-arm" runners. For reference, Debian 11 installs version 2.31 of the GNU C library (glibc), and Debian 12 installs glibc v2.36. Both of those versions of glibc set a default minimum Linux kernel version of 3.2.0: https://github.com/gnutools/glibc/blob/glibc-2.31/sysdeps/unix/sysv/linux/configure.ac#L4 https://github.com/gnutools/glibc/blob/glibc-2.36/sysdeps/unix/sysv/linux/configure.ac#L4 Prior to Linux kernel version 4.3.0, socket API system calls on 32-bit systems were implemented via the socketcall(2) system call: https://man7.org/linux/man-pages/man2/socketcall.2.html#VERSIONS https://man7.org/linux/man-pages/man2/socketcall.2.html#STANDARDS Hence on i386 systems the glibc library implements system calls such as socket(2) using socketcall(2): https://github.com/gnutools/glibc/blob/glibc-2.31/sysdeps/unix/sysv/linux/i386/kernel-features.h#L35-L44 https://github.com/gnutools/glibc/blob/glibc-2.31/sysdeps/unix/sysv/linux/socket.c#L29-L33 https://github.com/gnutools/glibc/blob/glibc-2.36/sysdeps/unix/sysv/linux/i386/kernel-features.h#L33-L44 https://github.com/gnutools/glibc/blob/glibc-2.36/sysdeps/unix/sysv/linux/socket.c#L29-L33 However, this hinders the use of seccomp(2) filters for these socket API system calls. Version 29.4.2 of the Moby project (the open-source portion of the Docker project) imports version 0.2.2 of the "seccomp" package from the "moby/profiles" Go module, and that version of the "seccomp" package includes a change which disables all access to the socketcall(2) system call: https://github.com/moby/moby/blob/docker-v29.4.2/go.mod#L68 https://github.com/moby/profiles/blob/seccomp/v0.2.2/seccomp/default_linux.go#L444-L463 Commit moby/profiles@7158007 of PR moby/profiles#21 implemented this change, noting: Since Linux 4.3, all affected architectures provide direct socket syscalls and modern glibc/musl already use them. Only very old statically-linked 32-bit binaries compiled against pre-4.3 glibc would be affected. This explains why all network activity is disabled in the 32-bit Docker containers our workflow jobs build using Debian 11 and 12. Fortunately, v0.2.3 of the "seccomp" package has been updated in commit moby/profiles@3c28324 of PR moby/profiles#23 to restore socketcall(2) calls, and version 29.4.3 of the Moby project imports the updated "seccomp" package: https://github.com/moby/moby/blob/docker-v29.4.3/go.mod#L68 https://github.com/moby/profiles/blob/seccomp/v0.2.3/seccomp/default_linux.go#L445-L463
… test on ubuntu-24.04, test.sh fixes ubuntu-latest (26.04) Docker 29.4.2 ile geliyor; o sürümün seccomp profili socketcall'u kapatıyor (moby/profiles#21, 29.4.3'te geri alındı; actions/runner-images#14790) ve 32 bit x86'da Go ile kiwix-serve ağa çıkamıyor. 386 işi Docker 28.0.4'lü ubuntu-24.04'e alındı; test.sh bu sürüm + 386'da güvenliği gevşetmeden nedeni yazıp duruyor. README'ye not. test.sh: reset-password kontrolü çıkış koduna bakıyor (pipefail + grep -q yüzünden arm/v6'da yanlış hata veriyordu); panel kapatılınca ana sayfa ve Kiwix açık kalıyor mu, panel geri geliyor mu kontrolü eklendi. ubuntu-latest (26.04) ships Docker 29.4.2, whose seccomp profile blocks socketcall (moby/profiles#21, reverted in 29.4.3; actions/runner-images#14790), so Go and kiwix-serve have no network on 32-bit x86. The 386 job moves to ubuntu-24.04 (Docker 28.0.4); on that version + 386 test.sh states the cause and stops instead of weakening the hardening. README note added. test.sh: the reset-password check uses the exit code (pipefail + grep -q gave a false failure on arm/v6); new checks that the homepage and Kiwix stay up while the panel is stopped and that the panel comes back.
ubuntu-latest (26.04) ships Docker 29.4.2, whose seccomp profile blocks socketcall (moby/profiles#21, reverted in 29.4.3; actions/runner-images#14790), so Go and kiwix-serve have no network on 32-bit x86. The 386 job moves to ubuntu-24.04 (Docker 28.0.4); on that version + 386 test.sh states the cause and stops instead of weakening the hardening. README note added. test.sh: the reset-password check uses the exit code (pipefail + grep -q gave a false failure on arm/v6); new checks that the homepage and Kiwix stay up while the panel is stopped and that the panel comes back. ubuntu-latest (26.04) Docker 29.4.2 ile geliyor; o sürümün seccomp profili socketcall'u kapatıyor (moby/profiles#21, 29.4.3'te geri alındı; actions/runner-images#14790) ve 32 bit x86'da Go ile kiwix-serve ağa çıkamıyor. 386 işi Docker 28.0.4'lü ubuntu-24.04'e alındı; test.sh bu sürüm + 386'da güvenliği gevşetmeden nedeni yazıp duruyor. README'ye not. test.sh: reset-password kontrolü çıkış koduna bakıyor (pipefail + grep -q yüzünden arm/v6'da yanlış hata veriyordu); panel kapatılınca ana sayfa ve Kiwix açık kalıyor mu, panel geri geliyor mu kontrolü eklendi.
The socket arg filters that block AF_ALG and AF_VSOCK only apply to the direct socket(2) syscall. On architectures with the legacy socketcall(2) multiplexer (i386, s390, MIPS o32), libseccomp auto-generates a socketcall(SYS_SOCKET) -> ALLOW companion for each socket ALLOW rule. This companion only checks the socketcall sub-command number, not the address family (behind a pointer BPF cannot dereference), bypassing the AF_ALG block for 32-bit binaries.
Add an explicit socketcall -> ERRNO(ENOSYS) deny rule placed before the socket allow rules. ENOSYS must be used instead of EPERM because the deny errno must differ from DefaultErrnoRet (EPERM): runc skips calling seccomp_rule_add() entirely when a rule's action matches the default action, so an EPERM deny is never passed to libseccomp and the auto-generated socketcall ALLOW path survives unchallenged. With ENOSYS, runc passes the rule through, and libseccomp replaces the auto-generated ALLOW path with ERRNO(ENOSYS) in the BPF.
Since Linux 4.3, all affected architectures provide direct socket syscalls and modern glibc/musl already use them. Only very old statically-linked 32-bit binaries compiled against pre-4.3 glibc would be affected.