Skip to content

✨ feat(v1.5): require_cpu_limit_hard + exec-create Env allowlisting - #121

Merged
scttbnsn merged 2 commits into
dev/v1.5from
feat/v1.5-spine-2
Jul 4, 2026
Merged

scttbnsn merged 2 commits into
dev/v1.5from
feat/v1.5-spine-2

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Second pair of the v1.5 spine, built per the specs from the prep workflow — the two parallel-safe items (disjoint config sections), each in its own worktree.

✨ request_body.container_create.require_cpu_limit_hard. New independent opt-in bool that requires a genuine CPU-time cap (HostConfig.NanoCpus or CpuQuota). The existing require_cpu_limit accepts CpuShares, but shares are a relative scheduling weight, not a cap — a shares-only container still eats 100% of an idle host. The new knob closes that gap without changing require_cpu_limit at all; enabling it alone is a complete configuration. A lone CpuPeriod doesn't satisfy it (it's just the CpuQuota denominator). cis-docker-benchmark.yaml deliberately does not enable it — CIS 5.11 is satisfied by CpuShares per the benchmark text, so forcing a hard cap would reject CIS-compliant workloads.

✨ request_body.exec.allowed_env_vars / denied_env_vars. Opt-in name-only restriction of exec-create Env entries. Denylist checked first and always wins; a non-empty allowlist denies unlisted names. Matching is exact and case-sensitive; values after = are never inspected or echoed into logs/deny responses, so secrets in allowed vars never leak. Both default empty = no restriction (deliberately the opposite default from allowed_commands) — zero behavior change unless configured. Create-time only: exec instances are immutable and GET /exec/{id}/json never returns Env, so there's nothing for the /exec/*/start re-check to re-validate. Docs ship a copy-pasteable linker-hijack denylist (LD_PRELOAD, LD_LIBRARY_PATH, LD_AUDIT, DYLD_INSERT_LIBRARIES, PYTHONPATH, PATH).

Both worktree-built, diff-reviewed, then integrated and re-gated on the combined branch: go build/test (all packages), golangci-lint 0 issues, full pre-push chain green. CHANGELOG carries both entries under [Unreleased]; README backlog row and configuration/security docs updated.

Remaining spine: namespace-sharing gate (last, serialized behind cpu-cap; pending the allow_cross_owner_namespace_sharing default decision).

scttbnsn added 2 commits July 3, 2026 22:24
- New opt-in bool `request_body.container_create.require_cpu_limit_hard`
  (default false), independent of the existing `require_cpu_limit` which
  stays byte-for-byte unchanged.
- New predicate `hasHardCPULimit`: NanoCpus > 0 OR CpuQuota > 0 counts as
  a hard cap; CpuShares and a lone CpuPeriod do not (relative priority,
  not an absolute ceiling). CpuQuota is accepted without a paired
  CpuPeriod — confirmed against Docker's docs that the CFS period
  defaults to 100000us when omitted.
- Enforced in containerCreatePolicy.denyResourceLimitReason independently
  of the base knob; when both are enabled and only CpuShares is set, the
  stricter hard-cap denial message wins.
- Wired through config.go, filter_options.go/ToFilterOptions, and
  filter/container_create.go (Options + policy struct); no manual
  v.SetDefault needed — the reflection-based Viper defaults walker
  (load.go) picks up the new mapstructure-tagged field automatically.
- Table-driven tests mirroring the existing require_cpu_limit cases
  (NanoCpus, CpuQuota-alone, CpuShares-alone rejection, CpuPeriod-alone
  rejection, both-knobs interaction, boundary mutation coverage) plus a
  filter_options_test.go propagation check.
- Docs: configuration.mdx (YAML example, policy reference table, env var
  table) and a CIS-benchmark callout explaining why the preset
  deliberately leaves the hard cap off (CIS 5.11 is satisfied by
  CpuShares).
- README roadmap: closes the CpuShares-vs-hard-cap backlog item; adds
  container-update re-validation and swarm-service CPU-limit parity as
  named follow-ups (out of scope here).
- CHANGELOG: Unreleased/Added + Tests entries.
- ✨ add `request_body.exec.allowed_env_vars`/`denied_env_vars` config
  fields, both opt-in and empty-by-default (no restriction), unlike
  `allowed_commands`' deny-all-when-empty
- ✨ enforce name-only, exact, case-sensitive matching on exec-create
  `Env` entries; denylist checked first and always wins; values are
  never inspected or logged
- ✨ fail closed on wrong-shaped `Env` JSON via a strictly-typed field
  (whole-body decode fails, same as other malformed exec bodies)
- 🧪 table-driven middleware/unit tests for deny-by-denylist precedence,
  allowlist rejection, passthrough when both empty, name-extraction
  edge cases, exec-start unaffected (Env never re-checked), config
  load/validate/YAML-override/per-profile/env-var coverage
- 🧪 extend FuzzExec seed corpus + harness with Env-bearing payloads
- 📝 document the new fields in configuration.mdx and security.mdx,
  including an example denylist (LD_PRELOAD, LD_LIBRARY_PATH, LD_AUDIT,
  DYLD_INSERT_LIBRARIES, PYTHONPATH, PATH) and the create-time-only
  enforcement boundary
- 📝 update CHANGELOG (Unreleased/Added) and README roadmap/feature rows
@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 2:34am

@scttbnsn
scttbnsn merged commit 4ed824d into dev/v1.5 Jul 4, 2026
45 checks passed
@scttbnsn
scttbnsn deleted the feat/v1.5-spine-2 branch July 4, 2026 02:39

This branch was successfully deployed

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