fix: make strict sandbox survive docker-compose services#139
Merged
Conversation
There was a problem hiding this comment.
2 issues found across 10 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/sandbox/macos.go">
<violation number="1" location="internal/sandbox/macos.go:668">
P2: Writable exposed host paths are not added to the read allowlist, so `ExposeHostPath(..., true)` can still be unreadable when `defaultDenyRead` is enabled.</violation>
</file>
<file name="internal/sandbox/manager.go">
<violation number="1" location="internal/sandbox/manager.go:113">
P2: Validate that ExposeHostPath targets an existing host path before accepting it; currently invalid paths are accepted and later ignored.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
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.
Summary
Three fixes for fence-sandboxed
docker compose up(and similar host-daemon-delegated services) on Linux. Each also cleans up a leaky abstraction that caused the underlying bug.--tmpfs /runon stock Ubuntu w/ systemd-resolved, wiping/run/docker.sock. The guard that would have prevented this was scoped todefaultDenyReadmode only; it now applies in both modes.Manager.SetService(ServiceOptions{..., ExecutionModel: ServiceBindsOnHost})lets callers signal that the sandboxed process delegates port binding to an external daemon (docker, podman, systemctl). Fence skips its reverse socat bridge in that case, avoiding a host-port collision with the daemon's own bind. ReplacesSetExposedPorts(breaking change).Manager.ExposeHostPath(path, writable)API. Emits a--ro-bind/--bindafter all tmpfs overmounts so callers can hand over a host-generated file (e.g. anos.CreateTemp("", ...)path under/tmp, which fence tmpfs-overmounts) without reverse-engineering fence's mount plan. On macOS, adds the path to the seatbelt allowlist.Changes
internal/sandbox/manager.go:ServiceOptions,ServiceExecutionModel,SetService,ExposeHostPath; replacesSetExposedPorts.internal/sandbox/linux.go: resolv.conf guard fix (+ TODO noting mountinfo-based shape); emits--ro-bind/--bindforExposedHostPathsafter tmpfs mounts; corrected misleading "non-recursive" comment on--ro-bind / /.internal/sandbox/macos.go: foldsExposedHostPathsinto seatbelt read/write allowlists.internal/sandbox/linux_stub.go: stub parity forExposedHostPaths.pkg/fence/fence.go: re-exportsServiceOptions,ServiceExecutionModel, enum constants.cmd/fence/main.go: new--service-execution-model,--expose-host-path,--expose-host-path-rwflags.manager_test.go(new) covers the API;linux_test.goadds two regression guards (exposed path under/tmpis bound AFTER--tmpfs /tmp).docs/library.mdupdated.Breaking
Manager.SetExposedPortsremoved. Callers migrate toManager.SetService(ServiceOptions{ExposedPorts: ...}). Default execution model (ServiceBindsInSandbox) preserves historical behavior.