Repository navigation
🔒 security(filter): close case-varied JSON key bypass class + timeout parity - #134
Conversation
… parity Rc-blocker bundle surfaced by the v1.5 correctness+completeness review — a recurring class where Docker decodes body keys case-insensitively (last duplicate wins) but sockguard re-marshals some bodies through a map that json.Marshal re-sorts, letting a shadow lowercase key win at the daemon a value the struct-decode filter never saw. - 🔒 security(filter,ownership): RejectDuplicateCaseVariantJSONKeys — reject fail-closed (400/403) any create/update body with duplicate case-variant JSON keys on every mutate-and-re-marshal path (owner-label stamp, image-digest pin, whole-body reorder). Closes owner-label spoofing (pre-existing since v1.0), cross-owner namespace hiding (v1.5-new check), and the cosign image-trust digest-pin bypass on containers/create + services/create,update (since v1.1.0). Case-insensitive collapse of a single lowercase variant keeps a legitimately lowercased field inspected and pinned. - 🔒 security(filter): exempt Docker's case-sensitive data-map fields (Labels, Annotations, Sysctls, Volumes, ExposedPorts, PortBindings, network/IPAM Options, DriverOpts/Opts, LogConfig.Config, EndpointsConfig, IPAM aux addresses) from the duplicate-key check at their own keys, while still descending through them so a struct nested inside a data map (EndpointSettings, an IPAMConfig array element) keeps its fold check — no false-positive on valid case-varying map keys, no bypass. - 🔒 security(filter): deny rather than forward when a cosign-verified image cannot be digest-pinned (PinnedReference error), closing the verify→pull TOCTOU fail-open edge in the container and service image-trust paths. - 🐛 fix(proxy): parse ?follow=/?stream= with daemon-accurate BoolValue semantics (only ""/0/no/false/none are false; stream defaults true when absent), and add plugin pull/push/upgrade to the long-lived upstream-timeout exemptions — prevents a spurious 504 on follow=yes and a wrongly-exempted stream=no now that the deadline defaults on. - 📝 docs: correct the unlabeled-target namespace wording (config comment + configuration.mdx — an unlabeled target is treated as untrusted and denied), fix the tri-tool bundled-presets anchor (15 → 17), and add the allow_host_cgroupns bullet to the website v1.5 milestone.
|
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 ignored due to path filters (1)
📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe pull request hardens Docker request handling across image trust, JSON rewriting, ownership middleware, and upstream timeout classification. Container and service image rewrites reject ambiguous case-variant keys and require successful digest pinning. Ownership processing normalizes case-insensitive namespace fields while rejecting duplicate variants. Docker-compatible query parsing and plugin endpoint exemptions update long-lived request detection. Configuration comments, documentation, a README link, and the roadmap were also updated. Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@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)
2154-2350: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a fuzz target for the JSON key validator.
RejectDuplicateCaseVariantJSONKeysis security-sensitive parsing; guidelines call for fuzzing filter/config parsing. AFuzzRejectDuplicateCaseVariantJSONKeys(stdlib, no deps) would exercise nesting/casing edge cases the table can't enumerate.func FuzzRejectDuplicateCaseVariantJSONKeys(f *testing.F) { f.Add(`{"HostConfig":{"a":1},"hostconfig":{"b":2}}`) f.Add(`{"Labels":{"Foo":"1","foo":"2"}}`) f.Fuzz(func(t *testing.T, body string) { _ = RejectDuplicateCaseVariantJSONKeys([]byte(body)) // must not panic }) }As per coding guidelines: "Use fuzz tests for filter matching and config parsing."
🤖 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 2154 - 2350, Add a standard-library fuzz test named FuzzRejectDuplicateCaseVariantJSONKeys alongside TestRejectDuplicateCaseVariantJSONKeys. Seed it with representative duplicate struct-field and case-sensitive data-object JSON inputs, then fuzz arbitrary body strings and call RejectDuplicateCaseVariantJSONKeys without asserting validity; the target must complete 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 `@app/internal/ownership/middleware.go`:
- Around line 365-407: Add "UTSMode" to the namespaceModeFields collection so
containerCreateNamespaceRefs also examines UTS namespace-sharing targets and
applies the existing cross-owner validation.
---
Nitpick comments:
In `@app/internal/filter/container_create_test.go`:
- Around line 2154-2350: Add a standard-library fuzz test named
FuzzRejectDuplicateCaseVariantJSONKeys alongside
TestRejectDuplicateCaseVariantJSONKeys. Seed it with representative duplicate
struct-field and case-sensitive data-object JSON inputs, then fuzz arbitrary
body strings and call RejectDuplicateCaseVariantJSONKeys without asserting
validity; the target must complete 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: 24f51443-d146-4fae-a15d-a66d4e545330
⛔ Files ignored due to path filters (1)
CHANGELOG.mdis excluded by!CHANGELOG.md
📒 Files selected for processing (12)
app/internal/config/config.goapp/internal/filter/container_create.goapp/internal/filter/container_create_test.goapp/internal/filter/service.goapp/internal/filter/service_test.goapp/internal/ownership/middleware.goapp/internal/ownership/middleware_test.goapp/internal/proxy/timeout.goapp/internal/proxy/timeout_test.godocs/content/docs/configuration.mdxexamples/compose/tri-tool/README.mdwebsite/src/lib/site-content.ts
Addresses CodeRabbit review on #134. HostConfig.UTSMode also honors the container:<name|id> form (moby's UTSMode has an IsContainer/Container form), so it belongs in the same namespace-sharing checks as NetworkMode/PidMode/IpcMode. It was missing from both, letting a UTS-namespace join slip past. - 🔒 security(ownership): add UTSMode to namespaceModeFields so the cross-owner container:<ref> check (ownership.owner deployments) resolves and denies a foreign-owner UTS-namespace join. - 🔒 security(filter): add UTSMode to denyNamespaceSharingReason so the opt-in restrict_namespace_sharing gate scopes UTS container:<ref> joins too, and correct the stale comment that claimed Docker has no container: form for UTS. - 🧪 test: cross-owner UTS deny (exact + lowercase-key) in ownership, UTSMode rows in the restrict_namespace_sharing matrix, and a FuzzRejectDuplicate CaseVariantJSONKeys stdlib fuzz target for the security-sensitive body walker. - 📝 docs(changelog): note UTSMode in the namespace-sharing bullets.
|
Both addressed in 4b28026:
@coderabbitai review |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
git log --oneline -5
git show 4b28026 --stat || true
echo "---UTSMode---"
rg -n "UTSMode" app/internal/ownership/middleware.go app/internal/ownership/middleware_test.go
echo "---namespaceModeFields---"
rg -n "namespaceModeFields" -A10 app/internal/ownership/middleware.go | head -60
echo "---denyNamespaceSharingReason---"
rg -n "denyNamespaceSharingReason" -A40 app/internal/filter -R 2>/dev/null | head -100
echo "---Fuzz target---"
rg -n "FuzzRejectDuplicateCaseVariantJSONKeys" -A30 app/internal/filter/container_create_test.goLength of output: 5703 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n "denyNamespaceSharingReason" -A40 app/internal/filter/*.go | head -80
echo "---fuzz---"
rg -n "FuzzRejectDuplicateCaseVariantJSONKeys" -A30 app/internal/filter/container_create_test.go
echo "---CHANGELOG---"
git show 4b28026 -- CHANGELOG.mdLength of output: 20234
No gaps in this diff. Triggering full review pass. ✅ Action performedReview finished.
|
What
The v1.5 rc-blocker bundle surfaced by an adversarial correctness+completeness review of everything v1.5 touches. Two independent workflow passes each caught a real defect that per-PR review and CodeRabbit missed; a third pass returned GO.
🔒 Case-varied JSON key bypass class (the main event)
Docker decodes create/update body keys case-insensitively and, on duplicate case-variant keys, honors the last after re-encode. Go's
json.Marshalemits map keys sorted, so a client's lowercase"image"/"hostconfig"sorts after — and overrides — the canonical key. Sockguard inspects via a case-insensitive struct decode, but several paths then re-marshal the body through a map whose re-sort moves a shadow key into the winning position, so the daemon acts on a value the filter never saw.Pre-existing instances, all now closed fail-closed:
ownershiplabel stampcom.sockguard.ownerwins → owner-identity spoof"hostconfig"/"networkmode"hides acontainer:<ref>join"image"survives cosign, daemon pulls unverified image"hostconfig"/nested"privileged"flips any already-cleared decisionFix:
RejectDuplicateCaseVariantJSONKeys— recursively reject (400/403) any body with twostrings.EqualFoldkeys, wired into all three re-marshal sites before they re-encode. A single lowercase variant is still collapsed to canonical so legit lowercased fields stay inspected/pinned. Docker's case-sensitive data maps (Labels,Sysctls,Volumes,EndpointsConfig, network/IPAMOptions,LogConfig.Config, …) are exempt at their own keys but the walk still descends through them, so a struct nested inside a data map (anEndpointSettings, anIPAMConfigarray element) keeps its fold check — no false positive on valid case-varying map keys, no bypass.Also closes a verify→pull TOCTOU fail-open edge: if a cosign-verified image can't be digest-pinned, the request is now denied rather than forwarded with the unpinned tag.
🐛 Upstream-timeout follow/stream parity
The long-lived-request classifier matched only
1/true/0/false, but dockerd'shttputils.BoolValuetreats everything except""/0/no/false/noneas true. Sologs?follow=yesstreams forever at the daemon yet got cut off with a spurious 504 under the new 60s default, andstats?stream=nowas wrongly exempted. Both now use daemon-accurateBoolValue/BoolValueOrDefault, and pluginpull/push/upgradejoin the long-lived exemptions.📝 Doc parity
Unlabeled-target namespace wording (config comment +
configuration.mdx), tri-tool bundled-presets anchor (15 → 17), website v1.5 milestone bullet forallow_host_cgroupns.Testing
RejectDuplicateCaseVariantJSONKeys(31 exemption cases incl. per-field positive + sibling-guard + the two nested-struct guards provingIPAM.Config/EndpointsConfigvalues are still fold-checked), ownership middleware end-to-end, image-trust regressions, timeout follow/stream + plugin exemptions.go test ./...green,golangci-lint0 issues, full pre-push suite green (incl. go-fuzz, govulncheck).Notes
The label-spoof (v1.0), image-trust (v1.1.0), and whole-body-reorder bypasses are live in released v1.4.x. Flagging for a possible
v1.4.2security backport decision separate from this v1.5 work.Changelog
RejectDuplicateCaseVariantJSONKeyswhile preserving Docker’s case-sensitive map keys only for the intended map-typed fields.HostConfig.UTSMode(includingcontainer:<ref>) whenrestrict_namespace_sharing/ ownership cross-owner sharing applies; addedUTSModecoverage to ownership + namespace-sharing gates.Imagerewriting for container-create and Swarm service payloads: fail-closed normalization to a single canonicalImagekey, collapse lowercase variants, and reject duplicate case-variantImagekeys; preserve unrelated JSON fields.follow/streamin logs/stats.POST /plugins/pull,POST /plugins/*/push, andPOST /plugins/*/upgrade.ownership.allow_cross_owner_namespace_sharingdefault behavior for unlabeledcontainer:<ref>targets in docs/config and update related content.Concerns / issues to address