Skip to content

Fix Cloud Hypervisor enclave session-log permissions - #11275

Merged
lpcox merged 7 commits into
mainfrom
copilot/fix-enclave-session-log-permissions
Nov 7, 2026
Merged

lpcox merged 7 commits into
mainfrom
copilot/fix-enclave-session-log-permissions

Conversation

Copilot AI commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Cloud Hypervisor enclaves failed shared session-log preflight before Copilot, Codex, or Claude could launch. The entrypoint’s UID did not match transcript ownership, and virtio-fs squashed guest root into the engine identity.

  • Separate writer and engine identities

    • Reserve root identity and existing SETUID/SETGID capabilities for the fixed trusted entrypoint.
    • Use effective UID/GID 65534 for ordinary I/O; permanently drop engine children to that identity.
  • Protect transcript storage

    • Stage /session-state as root-owned 0700, with session.jsonl mode 0600.
    • Preserve guest root translation only on the exact trusted transcript export; other mappings remain non-root.
  • Align preflight and append

    • Validate under the actual writer identity using the append-open path.
    • Reject unsafe ownership, modes, links, parent directories, and read-only mounts; retain bounded success/failure evidence.
  • Add boundary regressions

    • Exercise production staging, guest mounts, and launcher across all three engine selections, including legacy denial and engine isolation.
    • Engine/result checks use deterministic doubles; live VM/provider behavior remains unverified.

Copilot AI changed the title [WIP] Fix Cloud Hypervisor agent enclave session-log preflight permissions Fix Cloud Hypervisor enclave session-log permissions Nov 7, 2026
Copilot AI requested a review from lpcox November 7, 2026 18:50
@lpcox
lpcox marked this pull request as ready for review November 7, 2026 18:50
Copilot AI adaptive review requested due to automatic review settings November 7, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Both diagnostic collectors discard session permission metadata, and append-open failures lose the preflight record, leaving required diagnostic evidence unavailable.

1 open issue
What changed in this PR

This PR addresses shared session-log preflight failures in Cloud Hypervisor agent enclaves by separating trusted transcript writing from unprivileged engine execution.

Changes:

  • Move transcripts to root-owned /session-state storage with narrowly scoped root-preserving identity translation.
  • Align preflight and append operations with the trusted writer’s identity while permanently dropping engine privileges.
  • Add permission and isolation regressions across Copilot, Codex, and Claude using deterministic engine doubles; live VM/provider behavior remains unverified.
File Description
src/​enclave/​invocation-staging.ts Makes transcript location, ownership, and mode configurable.
src/​enclave/​invocation-staging.test.ts Checks private transcript staging for all three engines.
src/​cloud-hypervisor/​virtiofsd.ts Preserves root translation only for the trusted transcript export.
src/​cloud-hypervisor/​virtiofsd.test.ts Tests exact-source restrictions on root translation.
src/​cloud-hypervisor/​trusted-enclave-storage.ts Supplies the trusted transcript source to virtiofsd.
src/​cloud-hypervisor/​host-enclave-executor.test.ts Updates transcript fixtures to use session-state.
src/​cloud-hypervisor/​enclave-session-diagnostics.ts Reads transcripts from root-owned session-state storage.
src/​cloud-hypervisor/​enclave-session-diagnostics.test.ts Updates diagnostic fixtures for the new storage path.
src/​cloud-hypervisor/​enclave-invocation-staging.ts Stages root-owned transcript storage with restrictive permissions.
guest/​microvm-supervisor/​session_log_linux_test.go Adds staging, launcher, permission, and engine-isolation probes.
guest/​microvm-supervisor/​runtime_linux.go Reserves supervisor identity for the fixed trusted entrypoint.
guest/​microvm-supervisor/​runtime_linux_test.go Verifies rejection of arbitrary privileged agent commands.
guest/​microvm-supervisor/​resources_linux.go Points the transcript compatibility link to /session-state.
guest/​microvm-supervisor/​resources_linux_test.go Updates the expected transcript link target.
guest/​microvm-supervisor/​guest_probe_linux_test.go Integrates transcript probes into the guest boundary harness.
docs/​cloud-hypervisor-foundation.md Documents trusted-writer identity and transcript protection.
containers/​enclave/​agent-entrypoint.py Adds identity-scoped transcript access, stricter preflight, and engine privilege dropping.

Review effort: Max (auto)

Comment thread containers/enclave/agent-entrypoint.py Outdated
Comment on lines +632 to +636
"uid": path_stat.st_uid,
"gid": path_stat.st_gid,
"mode": stat.S_IMODE(path_stat.st_mode),
"writerUid": os.geteuid(),
"writerGid": os.getegid(),
@lpcox

lpcox commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Implemented and pushed as 2ec301b. Session preflight now records permission facts before append-open and writes a bounded stderr fallback on failure without retrying the transcript writer; both closed projections and regression tests retain the validated metadata. The microVM Go tests and direct smoke checks pass. Jest/build could not run because the locked package feed is unreachable.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-11275 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 5dd98f4

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@lpcox

lpcox commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve conflicts

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 93.78% 93.77% 📉 -0.01%
Statements 92.32% 92.30% 📉 -0.02%
Functions 93.02% 93.02% ➡️ +0.00%
Branches 86.58% 86.57% 📉 -0.01%
📁 Per-file Coverage Changes (5 files)
File Lines (Before → After) Statements (Before → After)
src/nvx/one-shot-process.ts 84.0% → 81.5% (-2.47%) 76.8% → 74.7% (-2.11%)
src/commands/main-action.ts 92.0% → 91.7% (-0.25%) 91.7% → 91.4% (-0.24%)
src/enclave/invocation-staging.ts 97.1% → 97.0% (-0.09%) 97.3% → 97.2% (-0.07%)
src/enclave/host-executor-server.ts 91.2% → 91.2% (+0.00%) 90.1% → 89.8% (-0.29%)
src/cloud-hypervisor/virtiofsd.ts 83.9% → 84.2% (+0.34%) 82.8% → 83.2% (+0.34%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copilot AI commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and resolve conflicts

Merged main cleanly and published the two-parent merge commit 689504c.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 93.77% 93.77% ➡️ +0.00%
Statements 92.31% 92.31% ➡️ +0.00%
Functions 93.02% 93.00% 📉 -0.02%
Branches 86.57% 86.56% ➡️ -0.01%
📁 Per-file Coverage Changes (7 files)
File Lines (Before → After) Statements (Before → After)
src/commands/main-action.ts 92.0% → 91.7% (-0.25%) 91.7% → 91.4% (-0.24%)
src/enclave/docker-host-executor.ts 95.0% → 94.8% (-0.18%) 89.5% → 89.4% (-0.10%)
src/enclave/invocation-staging.ts 97.1% → 97.0% (-0.09%) 97.3% → 97.2% (-0.07%)
src/enclave/host-executor-server.ts 91.2% → 91.2% (+0.00%) 89.8% → 90.1% (+0.29%)
src/enclave/public-debug-artifacts.ts 94.7% → 94.7% (+0.07%) 93.2% → 93.3% (+0.07%)
src/enclave/docker-host-recovery.ts 94.4% → 94.5% (+0.08%) 88.8% → 89.0% (+0.19%)
src/cloud-hypervisor/virtiofsd.ts 83.9% → 84.2% (+0.34%) 82.8% → 83.2% (+0.34%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 93.77% 93.77% ➡️ +0.00%
Statements 92.31% 92.30% 📉 -0.01%
Functions 93.00% 93.00% ➡️ +0.00%
Branches 86.56% 86.56% ➡️ +0.00%
📁 Per-file Coverage Changes (4 files)
File Lines (Before → After) Statements (Before → After)
src/commands/main-action.ts 92.0% → 91.7% (-0.25%) 91.7% → 91.4% (-0.24%)
src/enclave/invocation-staging.ts 97.1% → 97.0% (-0.09%) 97.3% → 97.2% (-0.07%)
src/enclave/host-executor-server.ts 91.2% → 91.2% (+0.00%) 90.1% → 89.8% (-0.29%)
src/cloud-hypervisor/virtiofsd.ts 83.9% → 84.2% (+0.34%) 82.8% → 83.2% (+0.34%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Preserve main's stderr fallback regressions using the protected transcript path.

Co-authored-by: Copilot App <[email protected]>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.80% 93.81% 📈 +0.01%
Statements 92.35% 92.36% 📈 +0.01%
Functions 93.02% 93.02% ➡️ +0.00%
Branches 86.67% 86.68% 📈 +0.01%
📁 Per-file Coverage Changes (4 files)
File Lines (Before → After) Statements (Before → After)
src/enclave/invocation-staging.ts 97.1% → 97.0% (-0.09%) 97.3% → 97.2% (-0.07%)
src/enclave/host-executor-server.ts 91.2% → 91.2% (+0.00%) 89.8% → 90.1% (+0.29%)
src/commands/main-action.ts 91.7% → 92.0% (+0.25%) 91.4% → 91.7% (+0.24%)
src/cloud-hypervisor/virtiofsd.ts 83.9% → 84.2% (+0.34%) 82.8% → 83.2% (+0.34%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

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.

Fix Cloud Hypervisor agent enclave session-log preflight permissions across Copilot, Codex, and Claude

4 participants