Skip to content

seccomp: Block AF_ALG in default socket policy#13327

Merged
AkihiroSuda merged 2 commits into
containerd:mainfrom
vvoland:fix-alg
May 12, 2026
Merged

seccomp: Block AF_ALG in default socket policy#13327
AkihiroSuda merged 2 commits into
containerd:mainfrom
vvoland:fix-alg

Conversation

@vvoland

@vvoland vvoland commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Addresses CVE-2026-31431.

Note: This doesn't block usage via socketcall.

AF_ALG (address family 38) exposes the Linux kernel crypto API to userspace via socket(2). Containers have no legitimate need for this interface under the default profile, and leaving it accessible widens the kernel attack surface unnecessarily (see https://copy.fail/).

The previous socket rule used a single "arg0 != AF_VSOCK" condition. Adding a second OpNotEqual for AF_ALG does not work because seccomp evaluates multiple argument conditions within a single rule as a logical AND against the same argument index.

Instead, restructure the socket allowlist into three range-based rules that cover every domain except AF_ALG (38) and AF_VSOCK (40):

  1. Allow socket when arg0 < 38 (all families below AF_ALG)
  2. Allow socket when arg0 == 39 (the single family between them)
  3. Allow socket when arg0 > 40 (all families above AF_VSOCK)

Domains 38 and 40 match none of the three rules and fall through to the default SCMP_ACT_ERRNO action.

Port of moby/profiles#20

@vvoland vvoland self-assigned this Apr 30, 2026
Copilot AI review requested due to automatic review settings April 30, 2026 19:35
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Apr 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the default Linux seccomp profile to reduce kernel attack surface by denying socket(AF_ALG, ...) (Linux crypto API) in addition to the already-denied AF_VSOCK, implemented via range-based argument filters on the socket syscall.

Changes:

  • Replaces the single socket(arg0 != AF_VSOCK) rule with three allow rules to exclude AF_ALG and AF_VSOCK.
  • Introduces < AF_ALG, == AF_ALG+1, and > AF_VSOCK comparisons to cover all other socket domains.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contrib/seccomp/seccomp_default.go
Comment thread contrib/seccomp/seccomp_default.go
Comment thread contrib/seccomp/seccomp_default.go
Add a comment explaining the purpose of the socket rules and noting that
on 32-bit x86, socket() goes through socketcall(2) which is allowed
unconditionally, so these arg filters only apply to the direct socket
syscall.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contrib/seccomp/seccomp_default.go Outdated
Comment thread contrib/seccomp/seccomp_default.go
Comment thread contrib/seccomp/seccomp_default.go Outdated

@samuelkarp samuelkarp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I tested this and the new seccomp rule appears to work.

When testing with ctr run:

  • The default is to use the image-provided UID/GID, so to force a non-root user use --user 1000:1000 (or similar)
  • "noNewPrivileges": true is default in the generated OCI config and this appears to prevent the PoC, so --allow-new-privs should be used
  • seccomp is disabled by default, but can be enabled with --seccomp
  • The docker.io/library/python:3 image is convenient for running the published PoC

Comment thread contrib/seccomp/seccomp_default.go Outdated
@samuelkarp samuelkarp added cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 labels May 1, 2026
@samuelkarp samuelkarp moved this from Needs Triage to Needs Reviewers in Pull Request Review May 1, 2026
Copilot AI review requested due to automatic review settings May 1, 2026 07:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 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.

@vvoland

vvoland commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

I also got moby/profiles#21 ready tonight.
It's slightly more controversial as it completely blocks socketcall, which shouldn't be an issue with any modern binary. So I think it's still ok to include - I will open it as a separate PR to consider, unless you want me to also include it here.

@samuelkarp

Copy link
Copy Markdown
Member

So I think it's still ok to include - I will open it as a separate PR to consider, unless you want me to also include it here.

Separate PR is good; I see you already opened #13330

Comment thread contrib/seccomp/seccomp_default.go Outdated
_ [38]byte = [unix.AF_ALG]byte{}
_ [40]byte = [unix.AF_VSOCK]byte{}
_ [1]byte = [unix.AF_VSOCK - unix.AF_ALG - 1]byte{}
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this assertion needed?
These constants are not platform-dependent
https://cs.opensource.google/go/x/sys/+/refs/tags/v0.44.0:unix/zerrors_linux.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, I meant it as "code as documentation" but reading it back I agree that's probably not that readable.

Removed it and turned it into a proper comment near the actual rules.

AF_ALG (address family 38) exposes the Linux kernel crypto API to
userspace via socket(2). Containers have no legitimate need for this
interface under the default profile, and leaving it accessible widens
the kernel attack surface unnecessarily (see https://copy.fail/).

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@github-project-automation github-project-automation Bot moved this from Needs Reviewers to Review In Progress in Pull Request Review May 12, 2026
@AkihiroSuda AkihiroSuda added this pull request to the merge queue May 12, 2026
Merged via the queue into containerd:main with commit 5674592 May 12, 2026
54 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review May 12, 2026
@AkihiroSuda

Copy link
Copy Markdown
Member

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0
/cherry-pick release/1.7

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@AkihiroSuda: new pull request created: #13406

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0
/cherry-pick release/1.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@AkihiroSuda: new pull request created: #13407

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0
/cherry-pick release/1.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@AkihiroSuda: new pull request created: #13408

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0
/cherry-pick release/1.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@AkihiroSuda: new pull request created: #13409

Details

In response to this:

/cherry-pick release/2.3
/cherry-pick release/2.2
/cherry-pick release/2.0
/cherry-pick release/1.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dmcgowan dmcgowan added cherry-picked/1.7.x PR commits are cherry-picked into release/1.7 branch cherry-picked/2.0.x PR commits are cherry picked into the release/2.0 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch and removed cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 labels May 20, 2026
@sathieu

sathieu commented May 22, 2026

Copy link
Copy Markdown

@dmcgowan @AkihiroSuda @vvoland Have you seen this revert: moby/profiles@3c28324 ?

@vvoland

vvoland commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

The revert was for that part: #13330 - not this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-picked/1.7.x PR commits are cherry-picked into release/1.7 branch cherry-picked/2.0.x PR commits are cherry picked into the release/2.0 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch kind/enhancement size/M

Projects

Development

Successfully merging this pull request may close these issues.

9 participants