Skip to content

fix(sandbox): separate terminal access from Agent grant inventory - #356

Merged
FumingZhang merged 2 commits into
feat/kata-kubernetes-accessfrom
fix/kubernetes-terminal-composition
Oct 29, 2026
Merged

FumingZhang merged 2 commits into
feat/kata-kubernetes-accessfrom
fix/kubernetes-terminal-composition

Conversation

@FumingZhang

Copy link
Copy Markdown
Member

Summary

Keep the isolated platform terminal's own access bindings separate from an Agent's policy-approved Kubernetes grants.

The local composition of #337 and #354 rejected Custom terminal workloads because the grant inventory classified terminal RoleBindings and the own-Agent reader ClusterRoleBinding as Agent Kubernetes grants. This change:

  • Shares the fixed terminal read-role definitions with inventory validation.
  • Recognizes only exact owner-bound terminal names, subjects, role references and current own-resource read rules; a terminal label alone is insufficient.
  • Keeps validated terminal bindings out of Agent grant submission, journal reconciliation and revocation, while retaining their normal terminal/namespace cleanup.
  • Rejects foreign owners, changed roles or subjects, broadened read rules, missing terminal workloads and unrecorded Agent grants.

Related issue

Discovered while composing #337 and #354 for the requested acceptance run.
This PR is deliberately stacked on #337, targeting feat/kata-kubernetes-access, rather than importing either complete feature branch into another feature PR. It does not add Custom execution to #337.

Validation

Offline checks used Go 1.27.3 and the existing pinned dependencies:

Command: go -C app/cetirun-operator test -race ./internal/sandboxpolicy ./internal/sandboxworkload ./internal/terminal -count=1 -timeout=5m
Result: passed all three packages.

Command: go -C app/internal test -race ./terminalpolicy -count=1
Result: passed, including fixed-role and malformed-authority cases.

Command: go -C app/cetirun-operator vet ./internal/sandboxpolicy ./internal/sandboxworkload ./internal/terminal
Result: passed.

Command: make -C app/cetirun-operator build
Result: passed.

Command: go -C app/cetirun-operator test ./internal/controller -run 'Test.*Terminal|Test.*Custom.*Deletion|Test.*Custom.*Suspension|TestSandboxHoldCustom' -count=1 -timeout=5m
Result: passed on the independently main-based inventory subset.

Command: make docs-check
Result: passed on the independently main-based inventory subset with pinned Hugo; 43 rendered pages checked.

Not run on this branch: the full repository gate, live provider permissions or a deployed Agent acceptance matrix.

In the separate local integration with #354, the original Custom terminal tests failed before this repair and passed afterward. The real local API-server terminal cases also passed for Kata/container contracts. Those tests use synthetic runtime observations and are not live VM, Cilium, CSI or interactive-terminal qualification.

Compatibility and operational impact

No CRD, dependency-version, runtime permission or timeout expansion. Existing Agent grant validation, write-ahead confirmation and cleanup remain fail-closed. The terminal retains its separate fixed authority; this does not grant model credentials or HOME access to its Pod.

The shared inventory correction was separately tested on current main. The grant-writer classification in this stacked diff depends on #337. Maintainer review is required before integration.

Checklist

  • The change is focused and preserves unrelated work.
  • Tests cover the changed behavior, or I explained why no new test is needed.
  • Documentation and examples match any public behavior changes.
  • Generated artifacts were updated from source, or none are affected.
  • Dependency changes include lockfiles, source attribution, and license information, or none are affected.
  • I checked the diff and attachments for secrets, private endpoints or identifiers, customer data, agent conversations, and internal information.
  • I followed the applicable CLA instructions, or asked a maintainer about an unclear check.
  • I identified checks that need credentials or a live environment and did not run them without authorization.

FumingZhang and others added 2 commits October 29, 2026 12:46
Keep exact owner-bound terminal access out of Agent grant recovery and revocation. Verify fixed binding subjects and live own-resource read roles rather than trusting a terminal label, and share the role contract with its producer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Validate the fixed terminal subject, role and rendered workload before excluding its RoleBindings from the Agent Kubernetes grant journal and guarded writer. Preserve rejection of missing labels, changed roles, foreign ownership and absent terminal workloads.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@feiskyer Pengfei Ni (feiskyer) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@FumingZhang
FumingZhang merged commit aea4a57 into feat/kata-kubernetes-access Oct 29, 2026
33 checks passed
@FumingZhang
FumingZhang deleted the fix/kubernetes-terminal-composition branch October 29, 2026 23:20
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.

2 participants