Skip to content

Output-cap enforcement is not equivalent across transports: kubectl kills only the local client #185

Closed

Description

@pdettori

Problem

The output cap is enforced by both per-call transports, but the enforcement is not equivalent — and the difference matters precisely in the threat model the cap exists for.

  • GrpcRelayTransport issues Abort, which travels to the worker and kills the remote process.
  • KubectlTransport calls child.kill("SIGKILL"), which kills only the local kubectl client. The in-pod process is then stopped by EPIPE on its next write to the now-closed stream — not by us.

That is adequate for well-behaved producers like cat or grep. It is not adequate for the case the cap is designed against. packages/k8s-sandbox/test/conformance.ts states the threat as a producer that "keeps burning the pod's CPU", and a hostile producer can trap or ignore SIGPIPE and keep spinning indefinitely after the client goes away. kubectl exec orphaning processes on client disconnect is long-standing upstream behaviour, not a corner case.

So on the in-cluster pod path, a malicious sandbox can survive the cap trip and continue consuming CPU. The harness stops reading it, which protects the model's context — the primary goal — but the secondary property implied by "stop the flood at the source" does not hold there.

Found in review of #184, which corrected the code comment that had asserted the stronger property and recorded the divergence in spec §8's "Accepted divergences".

Why the conformance battery cannot catch it

The shared battery reduces each transport's mechanism to a single producerStopped() boolean supplied by that transport's own factory. So:

  • the gRPC factory sets it from "the transport issued Abort for this exec's req_id" — the producer was genuinely told to stop
  • the kubectl factory sets it from "child.kill was called" — we killed our end

Both report true, and the battery is satisfied. The asymmetry is invisible by construction, which is why this needs a decision rather than a test.

The decision

  1. Accept it and leave the docs as they now stand. The cap's primary purpose — bounding what reaches the model — is met on both paths, and the secondary CPU-exhaustion property is only reachable by an already-hostile sandbox, which is the case persistentExecInPod (persistentExecInPod is an uncapped third SandboxTransport, and it serves the file-reading tools #180) and the deferred SPIFFE/mTLS work address more directly.
  2. Kill the in-pod process explicitly. The transport would need to issue a second kubectl exec to signal the process group, which means tracking a pid or wrapping every command in a shell that records one. That is real complexity on the hot path for every exec, to defend a case the pod path arguably should not be hosting at all.
  3. Make the battery able to see it, by having producerStopped() mean "the remote producer was told to stop" rather than "we invoked our local mechanism". That would fail the kubectl path honestly and turn this into a tracked gap rather than an invisible one — useful even if option 1 is chosen for the behaviour.

Option 3 is compatible with either of the others and is the cheapest way to stop the battery from over-reporting.

Refs

Found reviewing #184 · spec §8 "Accepted divergences" · sibling residuals #180, #181, #182 · epic #89.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions