Skip to content

✨ feat(v1.5): namespace-sharing gate — close cross-owner container:<ref> hole - #130

Merged
scttbnsn merged 7 commits into
dev/v1.5from
feat/v1.5-namespace-gate
Jul 10, 2026
Merged

scttbnsn merged 7 commits into
dev/v1.5from
feat/v1.5-namespace-gate

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

The final v1.5 spine item. Closes a real cross-tenant hole and adds structural gates for container-namespace-sharing modes on POST /containers/create.

The hole

allow_host_network/pid/ipc/userns only ever matched the literal "host" value on HostConfig.{NetworkMode,PidMode,IpcMode,UsernsMode}. A container:<id-or-name> value — which joins another container's namespace (shared sockets, process visibility, /dev/shm) — always passed through unchecked, invisible to owner-label isolation. ns:<path> on NetworkMode bypassed the "host"-literal check the same way.

Two independent layers

Filter tier (opt-in, zero behavior change unless enabled):

  • request_body.container_create.restrict_namespace_sharing (bool) + allowed_namespace_sharing_containers ([]string) — structurally deny/scope container:<ref> joins across all four fields.
  • request_body.container_create.deny_namespace_path_mode (bool) — deny ns:<path> on NetworkMode.

Ownership tier (the maintainer-approved default-behavior change):

  • ownership.allow_cross_owner_namespace_sharing (bool, default false). When ownership.owner is set, every container:<ref> target is resolved and the create is denied if that container belongs to a different owner. Set true to restore the old pass-through. This is the one v1.5 knob that intentionally changes default behavior — it only affects deployments that already set ownership.owner and relied on cross-owner container: sharing, which is itself the vulnerability. Shipped under a CHANGELOG Security entry.

Correctness notes

  • container:<ref> gating on NetworkMode/PidMode/IpcMode is real Docker syntax. UsernsMode container: and ns:<path> are belt-and-suspenders (stock Docker doesn't accept those forms) — implemented defensively, not over-claimed in docs, and no false-positive risk (Docker network names can't contain :).
  • Inspect error on a namespace target fails closed (502 reasonCodeOwnerPolicyLookupFailed), matching every other ownership check; not-found passes through (the daemon rejects a nonexistent container: target anyway).

Tests & gates (local)

gofmt clean, go build/go vet clean, full go test -race ./... green, CI-style production coverage 96.6% (floor 96%). Feature code by a worktree agent; tests by Codex; one generated test expectation (inspect-error → fail-closed) corrected during review.

Docs: configuration.mdx + security.mdx updated; README audit-backlog line for shared-namespace modes removed (now shipped).

Changelog

  • ✨ Added namespace-sharing filters for container:<ref> and ns:<path> modes.
  • 🔒 Added default cross-owner protection for namespace joins during POST /containers/create.
  • 🔧 Added ownership.allow_cross_owner_namespace_sharing escape hatch and configuration mappings.
  • 🔧 Added validation for namespace-sharing allowlist entries.
  • ✨ Added comprehensive filter and ownership middleware tests.
  • 🔧 Updated documentation and security guidance.
  • 🔧 Updated Go toolchain from 1.26.4 to 1.26.5.

Concerns

  • Verify Go 1.26.5 availability across all build and CI environments.
  • Confirm pass-through behavior for unresolved namespace-sharing targets matches deployment expectations.
  • Review compatibility for existing users relying on cross-owner namespace sharing.

scttbnsn added 5 commits July 10, 2026 13:44
…pace sharing

- allow_host_network/pid/ipc/userns only ever matched HostConfig's literal
  "host" value on NetworkMode/PidMode/IpcMode/UsernsMode; a container:<ref>
  value (join another container's namespace) always passed through
  unchecked, and still does by default.
- New request_body.container_create.restrict_namespace_sharing (+
  allowed_namespace_sharing_containers allowlist) denies container:<ref>
  joins across NetworkMode/PidMode/IpcMode/UsernsMode unless the target is
  allowlisted; empty allowlist denies all.
- New deny_namespace_path_mode denies NetworkMode=ns:<path>, Docker's raw
  host-namespace-file attachment form, which also bypasses the
  "host"-literal check.
- Both knobs default off/empty: zero behavior change unless enabled.
container:<ref> HostConfig.NetworkMode/PidMode/IpcMode/UsernsMode targets
were invisible to owner-label isolation: allow_host_network/pid/ipc/userns
only ever matched the literal "host" value, so joining another owner's
container namespace (shared sockets, process visibility, shared /dev/shm)
went unchecked wherever ownership.owner was already configured.

POST /containers/create now resolves every container:<ref> target
in-band with the existing owner-label injection pass and denies the
request if that container belongs to a different owner. Same-owner and
unlabeled-target refs are unaffected.

This is a deliberate default-behavior change, not opt-in: it only affects
ownership.owner deployments already relying on cross-owner container:
sharing. Restore the old unchecked behavior with the new
ownership.allow_cross_owner_namespace_sharing: true escape hatch.
…r check

Cover the new request_body.container_create.restrict_namespace_sharing /
allowed_namespace_sharing_containers / deny_namespace_path_mode knobs
(sample config, reference table, env-var table) and the
ownership.allow_cross_owner_namespace_sharing default-false cross-owner
container:<ref> check (sample config, Owner Label Isolation section,
env-var table, security.mdx Layer 6 writeup).
…t change

Add the three new request_body.container_create knobs to Unreleased/Added,
and a new Security subsection calling out
ownership.allow_cross_owner_namespace_sharing defaulting to false as this
release's one deliberate default-behavior change. Fold the now-shipped
container:<id>/ns:<path> audit-backlog line out of README's Post-1.0
preview table into the Shipping in v1.5 table.
Table-driven coverage for the container:<ref>/ns:<path> gate: ContainerNamespaceRef + isNamespacePathMode parsers, restrict_namespace_sharing allow/deny matrix across NetworkMode/PidMode/IpcMode/UsernsMode, deny_namespace_path_mode, filter-options mapping, and blank-entry validation. Ownership: cross-owner deny, same-owner/unlabeled/not-found handling, AllowCrossOwnerNamespaceSharing opt-out, ref dedup, and one-pass label-inject+ref-extract.

Corrected one expectation from the generated set: an inspect *error* on a namespace-sharing target fails closed (502 reasonCodeOwnerPolicyLookupFailed), not pass-through — matching the middleware's error convention for every ownership check. Tests written by Codex; this expectation fix + full -race/coverage gate run by review.
@vercel

vercel Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sockguard-website Ready Ready Preview, Comment Jul 10, 2026 6:32pm

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e3638dd-e739-418f-baf2-a409498c01c3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds configurable gates for container:<ref> and ns:<path> namespace modes during container creation. Adds default-deny cross-owner namespace sharing when ownership is enabled, including reference extraction, deduplication, ownership inspection, and owner-label injection. Adds configuration mapping and validation tests, filter and middleware coverage, documentation updates, release-note changes, and Go 1.26.5 toolchain updates.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/v1.5-namespace-gate

Comment @coderabbitai help to get the list of available commands.

GO-2026-5856 (Encrypted Client Hello privacy leak in crypto/tls) is fixed in go1.26.5. Sockguard reaches crypto/tls via the remote-upstream TLS dialer (internal/upstream/resolver.go) and the hijack read/write paths (internal/proxy/hijack.go), so govulncheck flagged it as reachable on 1.26.4. Bumps the toolchain directive in app/go.mod + benchmarks/go.mod and the Dockerfile builder base to golang:1.26.5-alpine3.23 (new index digest). Pre-existing on dev/v1.5 and main, surfaced by this PR's fresh CI run; verified locally that govulncheck reports 0 vulnerabilities on 1.26.5.
@scttbnsn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Line 4: Replace the Alpine-based image in the builder stage with the approved
Chainguard/Wolfi Go builder image, preserving the existing BUILDPLATFORM
targeting and digest pinning requirements.

In `@README.md`:
- Line 488: The namespace-sharing documentation incorrectly implies that
deny_namespace_path_mode covers all HostConfig namespace fields. Update the
README namespace-sharing gate entry and the corresponding configuration
documentation to state that ns:<path> is restricted only in NetworkMode, while
container:<ref> is checked across NetworkMode, PidMode, IpcMode, and UsernsMode.
- Line 489: Update the README Internals note to qualify the compatibility claim:
replace “No YAML key, env var, CLI flag, or default value changes” with wording
that only existing keys, flags, and default values remain unchanged by the
reflection refactor, while acknowledging that the PR adds new YAML fields and
SOCKGUARD_* variables.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3cb13026-5dd5-4e9b-8912-f762d5564977

📥 Commits

Reviewing files that changed from the base of the PR and between 1d6dfbc and e384092.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (17)
  • Dockerfile
  • README.md
  • app/go.mod
  • app/internal/cmd/serve.go
  • app/internal/config/config.go
  • app/internal/config/filter_options.go
  • app/internal/config/filter_options_test.go
  • app/internal/config/validate.go
  • app/internal/config/validate_test.go
  • app/internal/filter/container_create.go
  • app/internal/filter/container_create_test.go
  • app/internal/ownership/coverage_gap_test.go
  • app/internal/ownership/middleware.go
  • app/internal/ownership/middleware_test.go
  • benchmarks/go.mod
  • docs/content/docs/configuration.mdx
  • docs/content/docs/security.mdx

Comment thread Dockerfile Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
CodeRabbit review on #130 flagged that the namespace-sharing docs implied
deny_namespace_path_mode (ns:<path>) covers all four HostConfig namespace
fields. It only guards NetworkMode; container:<ref> is the form checked
across NetworkMode/PidMode/IpcMode/UsernsMode.

- README namespace-sharing gate row + configuration.mdx table cell now
  split the two mechanisms and their scopes.
- Qualify the reflection-refactor "no key changes" claim so it doesn't
  contradict the new namespace-sharing fields added in the same release.
@scttbnsn
scttbnsn merged commit 54e96a1 into dev/v1.5 Jul 10, 2026
46 checks passed
@scttbnsn
scttbnsn deleted the feat/v1.5-namespace-gate branch July 10, 2026 18:37
scttbnsn added a commit that referenced this pull request Jul 10, 2026
Brings main's v1.4.1 (Go toolchain 1.26.5 / GO-2026-5856) into the active
dev branch. The toolchain bump itself was already on dev/v1.5 via #130, so
the only new content is the CHANGELOG [1.4.1] Security entry and the README
latest-release prose flip to v1.4.1.

CHANGELOG conflict resolved keeping [Unreleased] (v1.5 spine) on top, then
[1.4.1], then [1.4.0].

This branch was successfully deployed

1 active deployment
Preview — 11f59b3e Deployed Jul 10, 2026 by vercel[bot]
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.

1 participant