seccomp: enforce the TCP bind allowlist on the on-behalf bind path - #227
Open
congwang-mk wants to merge 2 commits into
Open
seccomp: enforce the TCP bind allowlist on the on-behalf bind path#227congwang-mk wants to merge 2 commits into
congwang-mk wants to merge 2 commits into
Conversation
The bind allowlist was enforced only by Landlock BIND_TCP rules in the child. Any network supervision (net_allow, net_deny, the HTTP ACL, a policy function, port_remap) moves bind() onto the on-behalf path, where the supervisor binds a dup of the child's socket outside the child's Landlock domain. The kernel rules never saw the bind and the handler checked only the denylist, so the allowlist and the default deny-all silently stopped applying as soon as the sandbox also needed egress. The supervisor now carries the allowlist and refuses TCP binds outside it with EACCES, including bind(0), matching Landlock's behaviour on the direct path. Four Python port-remap tests bound ports without any allowlist and passed only because of the bypass; they now declare one. Signed-off-by: Cong Wang <cwang@multikernel.io>
Learn mode grants wildcard egress but never declared a bind allowlist, so its binds only succeeded through the on-behalf bypass that the previous commit closed. Observation has to see every bind the program attempts, so the allowlist is now the wildcard. Signed-off-by: Cong Wang <cwang@multikernel.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
--net-allow-bindwas enforced only by LandlockBIND_TCPrules in the child. Any network supervision (--net-allow,--net-deny, the HTTP ACL, a policy function,--port-remap) movesbind()onto the on-behalf path, where the supervisor binds a dup of the child's socket outside the child's Landlock domain. The kernel rules never saw the bind and the handler checked only the denylist, so the allowlist silently stopped applying as soon as the sandbox also needed egress.The default deny-all bind was bypassed the same way:
--net-allowalone or--port-remapalone let the sandbox bind any TCP port.Reproduction with
--net-allow-bind 18080:Fix
The supervisor's network state now carries the allowlist next to the existing denylist. The on-behalf bind handler refuses TCP binds outside it with EACCES, including
bind(0), matching Landlock on the direct path. UDP and non-IP binds are untouched. The allowlist is unset for the'*'wildcard, when a deny-bind policy is active, or when the NetTcp protection is not active, so those cases behave as before.Tests
net_allow,net_deny, andport_remap; the default deny-all underport_remap. Both failed before the fix.🤖 Generated with Claude Code