Skip to content

✨ feat(filter): wire insecure_allow_body_blind_writes into runtime exec policy - #123

Merged
scttbnsn merged 5 commits into
dev/v1.5from
feat/exec-policy-wiring
Jul 4, 2026
Merged

scttbnsn merged 5 commits into
dev/v1.5from
feat/exec-policy-wiring

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What

Closes the exec-policy gap from the tri-repo integration review (PICKUP item 4): insecure_allow_body_blind_writes was honored by the startup/reload/CLI validators but never reached filter.ExecOptions, so at runtime an empty allowed_commands denied ALL exec regardless of the flag — the documented opt-in was a silent no-op.

Changes

  • ExecOptions.AllowBlindWrites wired from cfg.InsecureAllowBodyBlindWrites in attachRuntimeInspectors. Scoped precisely: only the empty-allowlist gate is lifted; allow_privileged, allow_root_user, and env-var gates still apply exactly as configured. Default-deny remains the default, covered by tests.
  • One-time loud startup warning when the flag is set, listing which gates remain in force (matches the existing sync.Once warning pattern).
  • Preset audit (drydock, github-actions-runner, gitlab-runner, watchtower, portainer, portwing-with-exec): allowed_commands pins were already correct; fixed stale header prose in drydock presets (self-update now uses an ephemeral helper container, not in-process exec).
  • Hardening found by review: drydock-with-selfupdate.yaml pinned exec argv but left Env unrestricted — an allowlisted node exec could be subverted via NODE_OPTIONS. Now pins allowed_env_vars to the exact DD_SELF_UPDATE_* names drydock's buildFinalizeExecEnv() sends (verified against drydock dev/v1.6 source), with a conformance test proving a NODE_OPTIONS-carrying exec is denied.
  • Fixed factual bug in docs/content/docs/presets.mdx (claimed allow_root_user=false for the selfupdate preset; shipped YAML has it true).
  • README: DOCKER_GID → DOCKER_SOCK_GID prose/compose mismatch fixed.

Context

Surveyed the July 2026 socket-proxy field (Tecnativa, linuxserver, wollomatic, CetusGuard, 11notes, docker-proxy-acl, hawser): every one of them tops out at endpoint-level exec on/off — none inspect Cmd/Env/Privileged. sockguard's per-argv allowlisting + code-enforced blind-write gate already exceeded parity; this PR makes the documented escape hatch actually work and closes the env-injection corner.

Verification

Full go test ./... -count=3 -race in app/ clean; conformance suites updated (flag on/off, scoping, drydock env pin); reviewed independently by two adversarial passes.

scttbnsn added 5 commits July 4, 2026 09:05
The exec body-inspection policy had no idea the top-level
insecure_allow_body_blind_writes flag existed: an empty
request_body.exec.allowed_commands unconditionally denied every exec with
"no commands are allowlisted", regardless of the flag. The flag only ever
satisfied the startup validator (internal/cmd/rules.go), so every preset
that documents "set this flag to allow unpinned exec" was silently
non-functional for exec at request time.

- ExecOptions.AllowBlindWrites (filter/exec.go) lifts ONLY the
  "no commands are allowlisted" gate when AllowedCommands is empty;
  allow_privileged, allow_root_user, and allowed_env_vars/denied_env_vars
  still apply exactly as configured. The field has no effect once a real
  allowlist is pinned.
- attachRuntimeInspectors (cmd/serve.go) wires the global
  insecure_allow_body_blind_writes config value into it for both the
  default policy and every named client profile.
- withFilter now logs a startup warning (once per process, surviving
  hot-reload) naming exactly what the flag loosens, matching the existing
  warnIfLabelACLEnabled pattern.

Default-deny is unchanged: the flag must still be set explicitly.
Both drydock preset headers said "current Drydock does not spawn a
separate helper container" for self-update. As of drydock dev/v1.6
(SelfUpdateTransitionShared.ts / self-update-controller.ts, read via
ref-only git show against origin/dev/v1.6), that changed: drydock now
spawns a separate ephemeral AutoRemove helper container that itself issues
the stop-old/start-new/health-poll/finalize-exec/remove-old sequence over
the same bind-mounted socket, rather than drydock's own process doing so
directly.

The pinned allowed_commands argv in drydock-with-selfupdate.yaml
(["node", "dist/triggers/providers/docker/self-update-finalize-entrypoint.js"])
was independently verified against the current source and is still exactly
correct — only the "who calls exec" narrative needed updating.
- exec_test.go: flag off keeps the unchanged default-deny; flag on allows
  a clean exec but still denies privileged/root/denylisted-env execs; flag
  has no effect once AllowedCommands is pinned; a full-middleware HTTP case.
- portwing_preset_conformance_test.go: portwing-with-exec.yaml's exec-create
  assertion flips from denied to allowed now that the flag actually works,
  plus a new case proving the flag only lifts the allowlist gate (privileged
  exec still denies). TestMiddlewareDeniesUnallowlistedExecCreateCommand
  keeps the flag-off default-deny covered independently of any preset.
- drydock_preset_conformance_test.go: added a case with the full finalize
  exec-create body (AttachStdout/AttachStderr/Cmd/Env with the real
  DD_SELF_UPDATE_* names) proving Env doesn't affect the verdict.
- github/gitlab runner integration test helpers now wire
  insecure_allow_body_blind_writes the same way production does, so those
  presets' own opt-in takes effect in the integration harness too.
- serve_test.go/serve_warn_test.go/coverage_gaps_test.go: servePolicyConfig
  and buildServeClientProfiles both propagate the flag into
  PolicyConfig.Exec.AllowBlindWrites for the default policy and every named
  client profile; the new startup warning fires once per process and
  survives a simulated hot-reload.
- README's "Container runtime hardening" group_add snippet still used the
  pre-rename DOCKER_GID variable after every compose example switched to
  DOCKER_SOCK_GID — now consistent.
- security.mdx, configuration.mdx, and the README feature table now state
  that insecure_allow_body_blind_writes changes exec request-time behavior
  (not just startup validation): an unpinned exec is admitted instead of
  denied, but allow_privileged/allow_root_user/allowed_env_vars/
  denied_env_vars still gate it exactly as configured.
- presets.mdx's drydock-with-selfupdate.yaml summary said
  allow_root_user=false; the shipped preset (and its own YAML header) has
  always set it true — corrected, with the reasoning (empty exec User
  reads as root) restored.
- CHANGELOG entries for all of the above plus the new tests.
…LF_UPDATE_* set

drydock-with-selfupdate.yaml pinned exec Cmd via allowed_commands but left
exec Env completely unrestricted (exec.go's empty allowed/denied env lists
mean "no restriction"). For an interpreter command like node, Env can
change what the pinned argv actually executes — NODE_OPTIONS can --require
arbitrary code before the script runs, NODE_PATH can redirect module
resolution — so the "exact-argv pin keeps it safe" claim was overstated.

- 🔧 add allowed_env_vars to request_body.exec, scoped to exactly the
  DD_SELF_UPDATE_* names drydock's buildFinalizeExecEnv() sends
  (self-update-controller.ts), verified against drydock dev/v1.6 source
- 📝 update header/inline comments to describe the Env attack surface and
  why the argv pin alone doesn't close it
- 🧪 add a conformance case proving the same allowlisted Cmd with an extra
  NODE_OPTIONS Env entry is now denied, and correct a stale test comment
  that said Env was intentionally unrestricted
@vercel

vercel Bot commented Jul 4, 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 4, 2026 1:59pm

@scttbnsn
scttbnsn merged commit d8751ee into dev/v1.5 Jul 4, 2026
45 checks passed
@scttbnsn
scttbnsn deleted the feat/exec-policy-wiring branch July 4, 2026 14:09

This branch was successfully deployed

1 active deployment
Preview — 4192ac41 Deployed Jul 4, 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