Repository navigation
[Bubblewrap] Restrict socket address families and io_uring with an always-on seccomp filter - #1529
Open
Soham Das (SohamDas2021) wants to merge 1 commit into
Open
Soham Das (SohamDas2021) wants to merge 1 commit into
Soham Das (SohamDas2021) wants to merge 1 commit into
Conversation
…ways-on seccomp filter Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6e313a8c-149b-4c27-b3f7-06592ff192cd
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The filter rejects valid allowed-family socket calls with nonzero unused upper argument bits; compatibility paths also warrant human validation.
1 open issue
What changed in this PR
Adds an always-on Bubblewrap seccomp filter to block socket families that can bypass network isolation.
Changes:
- Restricts socket families and disables io_uring.
- Fails closed during filter setup and rejects unsupported architectures.
- Adds filter tests and documents compatibility limitations.
| File | Description |
|---|---|
src/mxc-sdk/tests/wxc_e2e_tests_e2e_bubblewrap_characterization.rs |
Adds socket-family and io_uring integration checks. |
src/mxc-sdk/src/backends/bubblewrap/common/seccomp_filter.rs |
Implements filter generation and interpreter tests. |
src/mxc-sdk/src/backends/bubblewrap/common/proxy_network.rs |
Exposes descriptor inheritance for filter delivery. |
src/mxc-sdk/src/backends/bubblewrap/common/mod.rs |
Registers the filter module. |
src/mxc-sdk/src/backends/bubblewrap/common/bwrap_version.rs |
Reports unsupported architectures as unavailable. |
src/mxc-sdk/src/backends/bubblewrap/common/bwrap_runner.rs |
Installs the filter during launch. |
docs/backends/bwrap/bubblewrap-backend.md |
Documents restrictions and compatibility. |
Review effort: Balanced
Comment on lines
+361
to
+368
| program.push(Instruction::statement( | ||
| BPF_LD_W_ABS, | ||
| SECCOMP_DATA_ARG0_HIGH_OFFSET, | ||
| )); | ||
| program.push(Instruction::jump(BPF_JMP_JEQ_K, 0)); | ||
| program.push(Instruction::statement(BPF_RET_K, errno(EPERM))); | ||
| let high_word_check = program.len() - 2; | ||
| program[high_word_check].jump_if_true = 1; |
This branch has not been deployed
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.

📖 Description
Sandboxed workloads could open AF_VSOCK sockets. The network namespace does not isolate VSOCK, so a workload could reach host or hypervisor services despite its egress policy. AF_PACKET and other unusual socket families were also unrestricted.
Every Bubblewrap launch now installs a seccomp filter:
socket()andsocketpair()succeed only for Unix-domain, IPv4, IPv6, and netlink sockets. Every other family, including VSOCK, packet, and future families, fails withEPERM.io_uring_setup,io_uring_enter,io_uring_register) fails withENOSYS. Without this, a workload could bypass the family check with io_uring'sIORING_OP_SOCKET. Programs that probe for io_uring fall back to ordinary syscalls.Limitations
socketcallpasses the family through a pointer that seccomp cannot inspect, so its socket-creation subcalls always fail withEPERM. Othersocketcalloperations still work.🔗 References
🔍 Validation
cargo fmt --all -- --check: passedcargo test -p mxc-sdk --lib seccomp_filter: 17 passed. These tests run the generated filter through a small test interpreter on every supported ABI.cargo test -p mxc-sdk --lib bwrap_version: passedcargo clippy -p mxc-sdk --lib --tests --target x86_64-unknown-linux-gnu -- -D warnings: passedcargo clippy -p mxc-sdk --lib --target aarch64-unknown-linux-gnu -- -D warnings: passedcargo test -p mxc-sdk --test wxc_e2e_tests_e2e_bubblewrap_characterization(WSL, kernel 6.18): 15 passed. New tests:EPERMfrom bothsocket()andsocketpair(). This test runs on every host.EPERM. This test skips if the host itself cannot create AF_VSOCK.io_uring_setupfails withENOSYS.IORING_OP_SOCKETreturned a working AF_VSOCK socket inside the sandbox. It now fails withENOSYS.✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes (see pull request builds)📋 Issue Type
GitHub Actions runs the PR validation build automatically. The ADO pipeline
(
MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with the GitHubActions build; it runs on merge to
main, and Microsoft reviewers with write access can trigger iton a PR with
/azp run. See pull request builds.If the
dependency-feed-checkcheck fails on a new dependency, the crate must be added tothe feed before the PR can pass. See pull request builds
for the steps.
Microsoft Reviewers: Open in CodeFlow