Repository navigation
🔒 security(filter): enforce endpoint-config policy symmetrically at create and connect - #136
Conversation
Aliases were denied at POST /networks/*/connect (unless allow_endpoint_config) but never enforced at container-create's primary network, so the check was bypassable and low-value. Docker Compose sets Aliases: [serviceName] on every endpoint it creates, so gating them broke every multi-network Compose recreate under the default policy. Links stays gated — it's a materially different, higher-privilege primitive. Extracts the field checks (static IP, MAC, Links, DriverOpts) into a shared denyEndpointConfigReason(ep, allow, subject) helper so the same logic can be reused by the upcoming container-create endpoint-config check.
…iner create POST /containers/create never inspected NetworkingConfig.EndpointsConfig, while POST /networks/*/connect already gated static IP/MAC/DriverOpts there unless allow_endpoint_config — a client (or a legitimate updater like drydock recreating a macvlan+static-IP container) could put the identical config on create's primary network and sail through unchecked. Real incident: drydock's connect call for the extra network got denied, but the create call for the primary network was never checked at all — a pure policy bypass, not a hardening gap. containerCreateRequest now decodes NetworkingConfig.EndpointsConfig; a new containerCreatePolicy.allowEndpointConfig field (from the same AllowEndpointConfig knob network already exposes) reuses denyEndpointConfigReason across every EndpointsConfig entry, iterated in sorted key order for deterministic denial messages. Also updates the network.go mutation-kill test that pinned the old combined Aliases+Links arithmetic, which no longer exists after the prior commit's alias fix.
…policy RequestBodyConfig.ToFilterOptions now copies c.Network.AllowEndpointConfig into the constructed ContainerCreateOptions after building it from ContainerCreateRequestBodyConfig. One existing flag (request_body.network.allow_endpoint_config) governs both the /networks/*/connect and the new /containers/create endpoint-config gates — no new YAML key, so a config that already sets allow_endpoint_config for connect automatically covers create's NetworkingConfig too.
…cident
The network-connect preset case was a trivial {"Container":"abc"} body that
never exercised EndpointConfig at all. Replaces/extends it with the shape
that actually broke: an aliases-only secondary-network connect (what every
multi-network Compose recreate sends, and what the alias-gating fix now
lets through by default — the regression test that would have caught the
incident) and the real macvlan+static-IP connect body drydock issues, which
must stay denied without allow_endpoint_config. A new
TestDrydockPresetNetworkConnectAllowEndpointConfigEscapeHatch proves the
documented opt-out actually admits that same body once the flag is set, on
both drydock presets.
… symmetry fix security.mdx and configuration.mdx (network group row, container_create group row, and the allow_endpoint_config env-var row) previously claimed a flat "endpoint static IP/MAC/alias/driver options" guarantee for POST /networks/*/connect only. Corrected: Aliases are always allowed at both endpoints (never gated); allow_endpoint_config now enforces static IP/MAC/links/driver options identically at POST /networks/*/connect AND POST /containers/create's NetworkingConfig.EndpointsConfig, via the same single flag. Also adds operator guidance to the drydock.yaml / drydock-with-compose.yaml preset headers: macvlan/static-IP/custom-MAC/endpoint-DriverOpts recreates need allow_endpoint_config: true, while alias-only multi-network compose recreates now work by default with no config change.
Unreleased entry: container-create now enforces the same endpoint-config gate connect already had (closes a bypass), aliases are no longer gated at either endpoint (a deliberate relaxation Compose needed), and a migration note for deployments relying on the pre-existing create-side gap.
…r create Docker's container-create body still honors a deprecated top-level MacAddress field (pre-API-1.44), applying it to the primary network endpoint exactly like NetworkingConfig.EndpointsConfig[*].MacAddress does. denyNetworkingConfigReason only inspected the EndpointsConfig form, so with allow_endpoint_config=false a client could still pin a MAC via the legacy root field — the same asymmetric-bypass class this inspector exists to close. Gate it with the same allow_endpoint_config flag and denial message.
….5.3 drydock >=1.5.3 rolls back cleanly on a connect/create denial (removes the half-created replacement, restores the name) so the container stays on its old image — only older drydock versions could leave an orphaned Created container. Reword the network endpoint-config comments in drydock.yaml and drydock-with-compose.yaml to reflect that while keeping the allow_endpoint_config guidance for macvlan/static-IP/ MAC-pinning setups.
…e shapes drydock >=1.5.3 only forwards a MacAddress when the user explicitly configured one, so its default-policy recreate is Aliases-only with no MacAddress — clarify that on the existing passing case. Add two denied- by-default cases for the pre-1.5.3 shape (which clones the operational MAC off inspect and forwards it on every recreate): Aliases+MacAddress on connect, and the same combination on create via NetworkingConfig.EndpointsConfig. Documents that older drydock versions still fail against the current default policy and need either the drydock upgrade or allow_endpoint_config: true.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe network endpoint-configuration policy now applies to both network connect requests and container creation endpoint settings. Container-create inspection checks endpoint fields and legacy root MAC addresses, while aliases remain allowed by default. Configuration wiring, regression tests, preset conformance tests, and documentation cover the shared policy and its override. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/internal/filter/container_create_test.go (1)
722-927: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a fuzz test for the new endpoint-config parsing/denial path.
denyNetworkingConfigReason/denyRootMacAddressReasonparse attacker-controlledNetworkingConfig.EndpointsConfigJSON to detect specific field shapes. Only fixed-table unit tests are added here; no fuzz coverage for this new filter-matching logic.As per coding guidelines,
app/**/*_test.goshould "Use fuzz tests for filter matching and config parsing."🧪 Sketch of a fuzz test seeded from existing table cases
func FuzzContainerCreatePolicyInspectEndpointConfig(f *testing.F) { seeds := []string{ `{"Image":"x","NetworkingConfig":{"EndpointsConfig":{"macvlan0":{"IPAMConfig":{"IPv4Address":"172.30.0.10"}}}}}`, `{"Image":"x","NetworkingConfig":{"EndpointsConfig":{"app-net":{"Aliases":["web"]}}}}`, `{"Image":"x","MacAddress":"02:42:ac:1e:00:0a"}`, } for _, s := range seeds { f.Add(s) } f.Fuzz(func(t *testing.T, body string) { req := httptest.NewRequest(http.MethodPost, "/containers/create", bytes.NewBufferString(body)) _, _ = newContainerCreatePolicy(ContainerCreateOptions{}).inspect(nil, req, "/containers/create") }) }🤖 Prompt for 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. In `@app/internal/filter/container_create_test.go` around lines 722 - 927, Add a fuzz test for the container-create endpoint configuration parsing and denial flow, using FuzzContainerCreatePolicyInspectEndpointConfig near the existing inspect tests. Seed it with representative static-IP, aliases-only, and root MacAddress payloads, then invoke newContainerCreatePolicy(ContainerCreateOptions{}).inspect with arbitrary request bodies and ensure the fuzz target completes without panicking.Source: Coding guidelines
🤖 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 `@docs/content/docs/configuration.mdx`:
- Line 249: The container_create documentation currently omits the legacy
top-level MacAddress behavior. Update the network group's allow_endpoint_config
documentation to state that POST /containers/create also gates the deprecated
top-level MacAddress field, alongside NetworkingConfig.EndpointsConfig.
---
Nitpick comments:
In `@app/internal/filter/container_create_test.go`:
- Around line 722-927: Add a fuzz test for the container-create endpoint
configuration parsing and denial flow, using
FuzzContainerCreatePolicyInspectEndpointConfig near the existing inspect tests.
Seed it with representative static-IP, aliases-only, and root MacAddress
payloads, then invoke newContainerCreatePolicy(ContainerCreateOptions{}).inspect
with arbitrary request bodies and ensure the fuzz target completes without
panicking.
🪄 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: 554c5d24-871e-4e17-8151-71ce4701cad0
⛔ Files ignored due to path filters (1)
CHANGELOG.mdis excluded by!CHANGELOG.md
📒 Files selected for processing (13)
app/configs/drydock-with-compose.yamlapp/configs/drydock.yamlapp/internal/config/filter_options.goapp/internal/config/filter_options_test.goapp/internal/filter/container_create.goapp/internal/filter/container_create_test.goapp/internal/filter/container_create_types.goapp/internal/filter/drydock_preset_conformance_test.goapp/internal/filter/mutation_kill_test.goapp/internal/filter/network.goapp/internal/filter/network_test.godocs/content/docs/configuration.mdxdocs/content/docs/security.mdx
Rollback on a denied endpoint-config request is best-effort, not guaranteed — if the rollback itself fails, drydock logs it to the update-operation history/audit log without a push notification.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Added the fuzz test in 4915db2: FuzzContainerCreatePolicyInspectEndpointConfig, seeded from the static-IP, aliases-only, root MacAddress, and case-variant-key table cases. 15s smoke run, 367k execs, no crashers. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
…e-pinning on recreate (#503) > [!IMPORTANT] > **Consolidated into v1.5.2-rc.5.** Merge after branch-protection approval, then dispatch `release-cut.yml` for `v1.5.2-rc.5` and restart the patch soak. The separate v1.5.3 train is retired. Companion PR: CodesWhat/sockguard#136. Root-caused from a real incident bundle (`drydock-npm-macvlan-incident-20260709`): a multi-network nginx-proxy-manager recreate behind sockguard's default-deny policy left an orphaned `Created` replacement squatting the canonical name, the original renamed `nginx-proxy-manager-old-…-old-…` (nested), silently broken ~4 weeks. ## Fixes - **Orphaned replacement recovery.** `createContainer` lost the created handle when a post-create network connect threw, so rollback couldn't remove the orphan and the rename-back 409'd. New `created-container-candidate` channel attaches the handle to the thrown error (connect failure *and* start-after-create failure); all rollback consumers (executor, self-update, health monitor, backup API, compose rollback-restore) recover and best-effort stop+remove it before restoring the original name. - **Rollback-cascade guard.** A container already named `-old-<epoch-ms>` refuses further updates with a "needs manual cleanup" error naming the true canonical name (nested suffixes stripped), instead of renaming again on top of the unresolved failure. Applies to regular and self-updates, and runs ahead of the dry-run check so dry-run surfaces the stuck state instead of masking it. - **MAC addresses are no longer re-pinned.** The recreate path copied each endpoint's operational `MacAddress` from inspect, permanently pinning daemon-assigned MACs (stale after IP changes, rejected by MAC-denying socket proxies). A MAC is now forwarded only when explicitly configured (`Config.MacAddress`, or `DesiredMacAddress` if daemons ever expose it), attributed only to the primary network (`NetworkMode: "default"` translated to `bridge`, mirroring moby's `IsDefault()`); the deprecated root-level create field is retained only for explicit MACs as an API<1.44 back-compat carrier. - **Locally-built images** (no `RepoDigests`) skip registry lookups instead of 401-ing into the nightly error count. - Digest-throttle warning no longer prints `with domain undefined` for unprefixed Docker Hub references. - Docs: socket-proxy requirements for static-IP/MAC recreates (Tecnativa `POST=1`+`NETWORKS=1`; sockguard `allow_endpoint_config`, create-side from sockguard v1.5.0), FAQ entry for `-old-<timestamp>` leftovers, CHANGELOG known-limitations (rollback-failure is audit-log-only; per-network `mac_address` on non-primary networks can't be preserved). ## Verification Two adversarial verification workflows (20 + 21 agents: dimension reviewers → independent refuters per finding → end-to-end completeness critic) plus a final deep-reasoner pass over the last delta. Each round confirmed real defects that were then fixed (round 1: 6 confirmed incl. the original fix not resolving the incident due to auto-MAC forwarding; round 2: 7 confirmed incl. compose rollback-restore dropping the orphan and MAC fan-out to every network; final pass: 3 incl. the `NetworkMode "default"` mismatch and an old-daemon MAC regression). Full pre-push gate green: 100% app+ui coverage, tsc, biome, qlty. Version files use the workflow-required base `1.5.2`; CHANGELOG heading `## [1.5.2-rc.5] — 2026-07-13`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Changelog - ✨ Added orphaned replacement-container candidate detection and best-effort stop/force-remove cleanup across Docker update, self-update, health-monitor rollback, backup rollback, and Compose rollback. - ✨ Added rollback-cascade protection to prevent further update/recreation when container names match the `-old-<timestamp>` rollback suffix pattern (including nested cases), including dry-run behavior. - 🔧 Changed Docker container recreation MAC handling to preserve only explicitly configured MACs on the primary network; auto-assigned endpoint MACs are dropped, with legacy `Config.MacAddress` compatibility. - ✨ Added local-image tracking (`image.isLocalImage`) to skip registry lookups for locally built/loaded images. - 🐛 Fixed orphan/candidate cleanup flows when failures occur after `createContainer` (connect/start failures) by attaching created-container handles to thrown errors and cleaning them up during rollback. - 🐛 Fixed Docker Hub digest-throttle warning formatting for unprefixed `docker.io` references. - 🐛 Fixed primary-network resolution when Docker reports `HostConfig.NetworkMode: "default"`. - ✨ Updated socket-proxy documentation and added FAQ guidance + rollback remediation notes. - ✨ Consolidated release updates/version files for `1.5.2-rc.5`. ## Concerns - Ensure the release is merged only after the v1.5.2 GA/branch-protection approval path, and verify `release-cut.yml` dispatch + patch-soak restart. - Double-check that rollback-named container prevention fully covers nested `-old-<timestamp>` suffixes without false positives. - Verify MAC precedence rules (auto-assigned vs desired vs legacy) across multi-network and “empty-string legacy MAC” scenarios. - Confirm Compose rollback candidate cleanup targets the correct candidate and does not double-remove. - Ensure `isLocalImage` is set/synced correctly so registry lookups are skipped only for truly local images. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
What
Closes the create/connect endpoint-config asymmetry found while root-causing a real production incident (drydock recreating a macvlan+static-IP container through sockguard defaults).
POST /containers/createnow inspectsNetworkingConfig.EndpointsConfig— static IPs, MAC addresses, links, and driver opts are gated by the existingrequest_body.network.allow_endpoint_configflag (default unchanged:false), identically to/networks/{id}/connect. Previously the same config passed create uninspected, making the connect-side gate a bypassable no-op.MacAddressfield is now gated too (the daemon still honors it on the primary endpoint — same bypass class).Aliasesare no longer gated at either endpoint. Compose sets a service-name alias on every endpoint, so alias-gating broke every multi-network compose recreate while providing no real boundary (it was never enforced at create). Links remain gated.allow_endpoint_config: true); conformance suite now covers the real incident shape plus the drydock ≥1.5.3 vs pre-1.5.3 payload difference.Why this shape
Decided via two independent design reviews then synthesized: keeping the default at
falsepreserves the documented static-IP/MAC posture, while symmetric enforcement turns the flag into a real control instead of connect-only theater. Flipping the default was rejected (withdraws a documented protection); gating aliases at create was rejected (breaks ordinary compose clients).Migration note
Deployments that were (knowingly or not) pinning static IPs/MACs via the create payload's endpoint config will start seeing denials — that path was an unchecked bypass of the documented policy. Set
request_body.network.allow_endpoint_config: trueto allow it.Verification
go build/go vet/golangci-lintclean;go test -race ./...all greenCompanion drydock PR (rollback hardening + no longer forwarding auto-assigned MACs) is on CodesWhat/drydock.
Changelog
request_body.network.allow_endpoint_configsymmetrically for endpoint config onPOST /networks/{id}/connectandPOST /containers/create(NetworkingConfig.EndpointsConfig), with endpoint aliases always allowed.MacAddressis also denied by default (empty string remains allowed).Network.AllowEndpointConfiginto container-create filter options (ContainerCreateOptions.AllowEndpointConfig) so connect/create can’t diverge.NetworkingConfig.EndpointsConfigand legacy rootMacAddress, including deterministic key iteration and nil endpoint skipping.MacAddresssemantics, and new fuzz coverage (FuzzContainerCreatePolicyInspectEndpointConfig).Concerns
MacAddressbehavior is exactly as intended (empty allowed, non-empty denied when flag is false).