Skip to content

✨ feat(filter): gate host cgroup namespace on container create (allow_host_cgroupns) - #133

Merged
scttbnsn merged 1 commit into
dev/v1.5from
feat/v1.5-cgroupns-gate
Jul 10, 2026
Merged

scttbnsn merged 1 commit into
dev/v1.5from
feat/v1.5-cgroupns-gate

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds request_body.container_create.allow_host_cgroupns (opt-in, default false), gating HostConfig.CgroupnsMode=host on POST /containers/create.

Why

This is the one host-namespace mode v1.5's own namespace-hardening pass missed. Commit c76ff4d (the v1.5 namespace-sharing gate) added the host-mode denial for UTSMode and the container:<ref> sharing gate across Network/PID/IPC/Userns — but CgroupnsMode was never parsed or gated. The decode struct didn't even carry the field, so cgroupns: host (share the host's cgroup namespace — a host-cgroup-hierarchy information-disclosure and cgroup-escape vector) passed straight through uninspected.

Surfaced by the post-v1.5 roadmap audit (workflow) as the only clean coherence gap in v1.5's shipped feature set — small, additive, opt-in, and it completes an already-shipped mechanism, so it belongs in this release rather than v1.6.

Changes

  • Gate: container_create.go — new allow_host_cgroupns rail, a mechanical mirror of the allow_host_userns wiring (config field → filter option → policy → inspect() gate). Denies CgroupnsMode=host unless opted in; case-insensitive + trimmed via the shared isHostNamespaceMode.
  • Decode struct: container_create_types.go — added the previously-missing CgroupnsMode field.
  • Defaults: none needed — the v1.5 reflection walker auto-registers the SOCKGUARD_REQUEST_BODY_CONTAINER_CREATE_ALLOW_HOST_CGROUPNS override off the struct (default false = zero value).
  • Presets: the three hardened presets that enumerate the host-namespace family (cis-docker-benchmark, github-actions-runner, gitlab-runner) now list allow_host_cgroupns: false explicitly (+ their examples/compose/ copies). No behavior change — they already denied it via the default — just self-documenting completeness. CIS gets an honest "no dedicated CIS control" comment.
  • Docs: CHANGELOG [Unreleased], configuration.mdx (example + key list), README "Shipping in v1.5" namespace-sharing row.
  • Tests: host/private/empty/mixed-case/whitespace cases + gate independence, via Codex.

Not in scope

The broader create/update-parity and swarm-service-parity gaps the same audit found are real but need design calls / are M/L — they're the v1.6 "Create/Update Parity & Resource-Limit Hardening" theme, not this release. See .planning/v1.6-roadmap.md.

Changelog

  • ✨ Added allow_host_cgroupns configuration, defaulting to false.
  • 🔒 Blocked HostConfig.CgroupnsMode=host unless explicitly allowed.
  • 🔧 Added case-insensitive, whitespace-tolerant mode detection and request decoding.
  • 🔧 Updated hardened presets, compose examples, documentation, and README.
  • ✨ Added coverage for supported modes, formatting variants, and independent policy gates.

allow_host_cgroupns (opt-in, default false) denies HostConfig.CgroupnsMode=host
on POST /containers/create. It's the one host-namespace mode v1.5's namespace-
hardening pass missed: c76ff4d added the host-mode denial for UTSMode and the
container:<ref> sharing gate across Network/PID/IPC/Userns, but CgroupnsMode was
never parsed or gated — the decode struct didn't even carry the field, so
cgroupns:host (host cgroup-hierarchy disclosure + cgroup-escape vector) passed
through uninspected. Mechanical mirror of the allow_host_userns wiring.

- ✨ feat(filter): allow_host_cgroupns rail + CgroupnsMode decode field + gate
- 🔧 config(presets): list allow_host_cgroupns: false in the three hardened
  presets (cis, github-actions-runner, gitlab-runner) + compose copies
- 📝 docs(changelog,readme,config): document the new opt-in
- 🧪 test(filter): host/private/empty/case/whitespace + gate-independence cases

Defaults handled by the v1.5 reflection walker (no manual SetDefault). Found by
the post-v1.5 roadmap audit as the only clean coherence gap for the rc.
@scttbnsn

Copy link
Copy Markdown
Contributor Author

@coderabbitai 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 11:46pm

@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e169c8f0-5c4b-46d0-9afd-c1629a293cae

📥 Commits

Reviewing files that changed from the base of the PR and between 8a0bb77 and 7a42f67.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (14)
  • README.md
  • app/configs/cis-docker-benchmark.yaml
  • app/configs/github-actions-runner.yaml
  • app/configs/gitlab-runner.yaml
  • app/internal/config/config.go
  • app/internal/config/filter_options.go
  • app/internal/config/filter_options_test.go
  • app/internal/filter/container_create.go
  • app/internal/filter/container_create_test.go
  • app/internal/filter/container_create_types.go
  • docs/content/docs/configuration.mdx
  • examples/compose/cis-docker-benchmark/sockguard.yaml
  • examples/compose/github-actions-runner/sockguard.yaml
  • examples/compose/gitlab-runner/sockguard.yaml

📝 Walkthrough

Walkthrough

Added allow_host_cgroupns configuration and filter support for container creation. Requests using HostConfig.CgroupnsMode=host are denied by default, with an explicit option to allow them. Request decoding, policy mapping, and inspection tests cover the new behavior. Built-in presets, compose configurations, documentation, and release notes now describe or disable host cgroup namespace sharing.

🚥 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/v1.5-cgroupns-gate

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

@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.

@scttbnsn
scttbnsn merged commit e7ae38f into dev/v1.5 Jul 10, 2026
46 checks passed
@scttbnsn
scttbnsn deleted the feat/v1.5-cgroupns-gate branch July 10, 2026 23:55

This branch was successfully deployed

1 active deployment
Preview — 7a42f671 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