Skip to content

apparmor: Deny AF_ALG sockets in default container profile#22

Merged
thaJeztah merged 1 commit intomoby:mainfrom
vvoland:fix-socketcall
May 6, 2026
Merged

apparmor: Deny AF_ALG sockets in default container profile#22
thaJeztah merged 1 commit intomoby:mainfrom
vvoland:fix-socketcall

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented May 5, 2026

apparmor: Deny AF_ALG sockets in default container profile

The AF_ALG address family exposes the Linux kernel crypto API to userspace via sockets. This has been a source of container escape vulnerabilities (see https://copy.fail/).

Unlike seccomp, which can only filter arguments of the direct socket(2) syscall, AppArmor hooks into the kernel's security_socket_create() LSM callback, which fires regardless of the syscall entry point. This means AppArmor also blocks AF_ALG sockets created via the legacy socketcall(2) multiplexer (used by 32-bit binaries), which seccomp cannot inspect because the address family is behind a userspace pointer that BPF cannot dereference.

The "deny network alg," rule is placed right after the blanket
"network," allow rule so the deny takes precedence for this specific address family.

The AF_ALG address family exposes the Linux kernel crypto API to
userspace via sockets. This has been a source of container escape
vulnerabilities (see https://copy.fail/).

Unlike seccomp, which can only filter arguments of the direct socket(2)
syscall, AppArmor hooks into the kernel's security_socket_create() LSM
callback, which fires regardless of the syscall entry point.
This means AppArmor also blocks AF_ALG sockets created via the legacy
socketcall(2) multiplexer (used by 32-bit binaries), which seccomp
cannot inspect because the address family is behind a userspace pointer
that BPF cannot dereference.

The "deny network alg," rule is placed right after the blanket
"network," allow rule so the deny takes precedence for this specific
address family.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland self-assigned this May 5, 2026
@vvoland vvoland requested a review from thaJeztah May 6, 2026 09:50
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah merged commit f2c4515 into moby:main May 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants