← Back to Pull requests

feat(node-image): seal post-start exec at the runc boundary #609

Closed
unknown closed this pull request without merging on Sep 22, 2026 17:42 UTC
View on GitHub
unknown unknown commented on Sep 14, 2026 11:16 UTC
Author

Why

The kubelet runs exec liveness/readiness/startup probes and postStart/preStop hooks through CRI ExecSync, and kubectl exec/cp reach the same runtime call. enable-debugging-handlers=false closes only the kubelet's HTTP API: none of the other paths passes through it, and none fires an NRI hook. On a measured node image, anyone who can put argv in a probe field of an admitted pod gets code execution inside a running container and reads the output back from pod events.

Separately, nothing proved that no container was running when the image-policy plugin registered. The plugin is pre-registered in the image's containerd config and required_plugins blocks creation while it is absent, but the ordering that makes that true is asserted by systemd, not by the enforcer.

Description

c8s-runc, a measured runtime wrapper (internal/cmds/c8srunc, cmd/c8s-runc). containerd's runc shim runs the binary named by the runtime handler's BinaryName for every verb, so a wrapper there sees every request that starts a process in a running container. A locked build denies the exec verb and execves the real runc for every other verb with the original argv, environment and file descriptors. The posture is a build-time constant — no mode file, no allowlist, nothing on a running node changes it. Global options are parsed only to find the subcommand, modelled on the runc the pinned RKE2 ships; an option the wrapper does not recognise is a denial, because a token modelled wrongly shifts which argument the subcommand is. The denial is also written to runc's --log in --log-format, so containerd surfaces it in the pod event instead of an empty runtime error. The node image installs it as an argv alias of the c8s binary, dispatched by basename before cobra sees runc's argv.

Image wiring. mkosi.sync installs the wrapper at /usr/local/bin/c8s-runc; the baked drop-in config-v3.toml.d/10-c8s-runc.toml points the runc handler's BinaryName at it. A drop-in rather than a template line: RKE2's base template already defines that table and containerd's TOML parser rejects a duplicate; containerd merges each import over the main config key by key. C8S_DEV=1 renders a later drop-in restoring the unwrapped runtime, from the same variant switch that re-enables the kubelet debugging handlers — the two images already have different measurements.

Build gate. node-guest-image/c8s/containerdcheck renders the profile's template the way RKE2 does (its base template vendored and pinned to the RKE2 release), merges the drop-ins containerd imports, and asserts every enabled ordinary-pod handler runs the wrapper — failing on an empty BinaryName, an alternate runc, a later drop-in that unwraps the handler, an unaudited shim, or a default_runtime_name that is not wrapped. The invariants gate adds what a rendered config cannot show: the wrapper path the build installs, the real-runtime path the wrapper is compiled with, the absence of any runtime binary RKE2's auto-detection would add a handler for (crun, the nvidia runtimes, the wasm shims), and the base-template pin against RKE2_VERSION. go-toml moves from an indirect to a direct dependency; it is what containerd parses the same file with.

The vendored base template follows the k3s revision behind RKE2 v1.36.4. Since k3s b51167a9 that base emits the config-v3.toml.d/*.toml import itself, so the baked config-v3.toml.tmpl no longer prepends its own imports line: the gate rendered the old template as a duplicate TOML key.

Chart. c8s-owned exec probes and the one lifecycle exec hook are replaced, since neither can pass on such a node:

  • attest-proxy --health-addr serves GET /healthz by making the same round-trip over its own socket the healthcheck subcommand makes; readiness and liveness use it.

  • ratls-mesh iptables-sync --ready-addr serves GET /readyz on node loopback; the startup probe that gates the mesh proxy reads it.

  • The mesh cleanup sidecar runs iptables-cleanup --keep-guard --on-shutdown, which idles until SIGTERM and then cleans up, in place of the preStop hook. Native sidecars stop in reverse init order, so the ordering is unchanged; ratlsMesh.iptablesCleanup.preStopSleepSeconds now renders --settle-delay.

  • acme --ready-port serves GET /readyz, reporting the same condition nginx's probe-file exec probe reported.
  • New values: attestationApi.proxy.healthPort (8401), ratlsMesh.ports.iptablesReady (15022), and the chart-internal router.acmeReadyPort helper (8403). A chart test walks every rendered manifest for exec probes and lifecycle exec hooks.

    Image-policy plugin. New policy.fatal_existing (with policy.boot_marker_path, validated to require fail-closed mode, enforce_existing, and an absolute tmpfs path): a container present at the plugin's first registration after boot has already run, so stopping it proves nothing — the plugin logs every container it was handed and powers the node off. A plugin restart is a different event, since containerd stays up and its containers legitimately predate the new process, so a boot-scoped marker separates the two: a restart re-checks what is running through the existing startup check and escalates only there. Not while the first pull after that restart is outstanding — the plugin is Ready on the boot floor alone then, and every workload the allowlist service admitted would look unknown; that case keeps the existing stop. If the power-off syscall is refused the plugin exits, which leaves required_plugins blocking every new container. The setting is off by default, so the chart's containerised plugin is unchanged; the node image's baked config turns it on.

    Focus areas for review

  • parseGlobals in internal/cmds/c8srunc/c8srunc.go: the flag model is taken from the runc version the pinned RKE2 ships, and the deny-on-unknown-option rule is what keeps a future runc flag from turning into a pass-through.

  • The wrapper's real-runtime path is RKE2's extracted runc under its bin symlink. RKE2 keeps that directory on containerd's PATH, so runc still resolves by name for a process already running as root on the node; no enabled handler uses it. docs/node-exec-mode.md "Known limits" states this.

  • The dev drop-in is rendered into a directory that also exists in the profile's mkosi.extra; extra-tree precedence for a shared directory is worth confirming on the first dev build.

  • Whether powering the node off is the right action for a container found at first registration, and whether the "no escalation before the first allowlist pull" carve-out is drawn in the right place.

  • Probe substitutions: /healthz and /readyz are reachable from other pods (the mesh one only from node loopback). They report liveness or file existence and carry no evidence.
  • Not covered here

  • Reporting the exec posture from a verified image manifest, so a relying party can tell a locked image from a debug one without comparing measurements: follow-up.

  • The image cannot be built in this environment, so the installed binary, the rendered dev drop-in and the config RKE2 writes at boot are unverified outside the fixtures.

  • runc checkpoint and restore are not aliases of exec and pass through; they deserve their own audit.
  • Related: https://github.com/confidential-dot-ai/c8s/pull/584, https://github.com/confidential-dot-ai/c8s/pull/585

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: joaosa Review duration: 11906m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #609"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%