Repository navigation
fix(security): phase-1 agent VM /health auth (keep NAT, defer private cutover) - #10391
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed8fdf0a9f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
809cedd to
9d9379f
Compare
|
Monitor run — firewall update idempotency fix
Pre-existing backend unit failure (not addressed here): |
kodjima33
left a comment
There was a problem hiding this comment.
agent VM /health auth — approved; touches auth so not auto-merged, flagged for Nik
9d9379f to
92ef6d7
Compare
|
Monitor run — rebased onto current main Rebased this branch onto the latest After rebase, Desktop Swift Static Contracts now passes (was failing before on the stale base). The remaining CI failures (Backend unit suite, Public Developer API contract) are pre-existing
The PR's own tests ( |
92ef6d7 to
93d9786
Compare
|
Monitor run — rebased onto latest main (09ce8a7) Rebased this branch onto the latest Verification before push:
Check status after rebase:
Review threads: The single Codex P2 thread (firewall create-only flags) remains resolved. No new review comments on the rebased head. |
Unauthenticated GET /health leaked databaseReady on public :8080. Require the existing VM token (Bearer or ?token=) and update agent-proxy + desktop health callers so readiness probes keep working. Verification: python3 -m pytest backend/tests/unit/test_agent_vm_health_auth_contract.py -v Related #7326 Failure-Class: new Co-authored-by: Cursor <[email protected]>
Extract insert-body/IP helpers and lock ONE_TO_ONE_NAT + omi-agent-vm tag so phase-1 hardening cannot accidentally drop public reachability. Verification: cd desktop/macos/Backend-Rust && cargo test agent::contract Related #7326 Failure-Class: none Co-authored-by: Cursor <[email protected]>
Prepare private-allow + public-deny rules for tag omi-agent-vm, but
refuse apply by default (AGENT_VM_FIREWALL_APPLY_PHASE3 gate). Do not
apply to prod until desktop upload/sync is proxied and cross-VPC
reachability exists.
Verification: python3 -m pytest backend/tests/unit/test_agent_vm_firewall_contract.py -v
bash backend/scripts/apply-agent-vm-firewall.sh # exits 1 REFUSED
Related #7326
Failure-Class: none
Co-authored-by: Cursor <[email protected]>
Related #7326 Failure-Class: none Co-authored-by: Cursor <[email protected]>
desktop/macos/AGENTS.md already exceeds its byte budget on main; any AGENTS.md touch selects agents-md-lean and fails. Deferred firewall docs remain in backend/charts/agent-vm-firewall/firewall-rule.yaml and apply-agent-vm-firewall.sh. Related #7326 Failure-Class: none Co-authored-by: Cursor <[email protected]>
Records the #7326 phase-1 contract: public agent VM /health must not expose readiness without the VM token. Evidence: prior attempt #9261. Failure-Class: none Co-authored-by: Cursor <[email protected]>
gcloud compute firewall-rules update rejects --action, --direction, and --network (immutable after creation). The apply script reused a single GCLOUD_ARGS array for both create and update, so updating an existing rule during phase-3 cutover would fail instead of refreshing. Split into UPDATE_ARGS (mutable attributes) + create-only flags appended only to the create path. Added a static contract test that asserts the update line omits immutable flags while the create block still carries them. Addresses Codex review PRRT_kwDOLkKqys6TJ8pP.
93d9786 to
dd7a8ec
Compare
|
Rebased onto latest Backend agent-vm health auth and firewall contract tests pass; Swift file parses clean. All checks green. |
|
#10686 supersedes the agent.mjs publication step with a versioned Python VM image and GCS startup artifact. Keep this PR’s health-auth rollout order when resolving overlap. |
|
@cursor address merge conflicts |
|
Merge conflicts are resolved and pushed to What conflicted: Resolution:
Unchanged (already merged cleanly): Swift callers ( Verification: All 9 PR-specific backend contract tests pass. Rollout note: The PR's manual step to publish |
Main retired agent.mjs and Backend-Rust agent.rs in favor of backend/agent_vm and routers/desktop_agent_vm.py. Port /health auth gating and contract tests to the Python surfaces; drop the deleted Node/Rust files instead of keeping stale edits. Verification: pytest test_agent_vm_health_auth_contract.py test_agent_vm_firewall_contract.py test_agent_vm_protocol (health auth) Co-authored-by: David Zhang <[email protected]>


Summary
Phase-1, low-blast-radius harden for agent VM public
:8080exposure (#7326) — without removing public NAT or applying a public DENY firewall (those break prod today).Why not private-only yet: agent VMs are on VPC
default;agent-proxyis on GKEomi-prod-vpc-1with no peering. Desktop still callshttp://{vmIP}:8080for upload/sync. Removing NAT or denying0.0.0.0/0would break chat + DB sync.This PR (safe to merge)
ONE_TO_ONE_NAT/ public IP provisioningomi-agent-vmnetwork tag/health(was publicly readabledatabaseReady); update desktop + agent-proxy callersAGENT_VM_FIREWALL_APPLY_PHASE3gate)backend/charts/agent-vm-firewall/firewall-rule.yaml+ apply script (refuse-by-default)Explicitly deferred (do not apply yet)
Partial progress on #7326 (auth harden + prepare surface; not full network isolation or cost fix).
Supersedes #9261 (stale/CONFLICTING since Jul 12).
Product invariants affected
AgentSyncService.swift; this PR only adds Bearer/?token=on VM/healthprobes — no Firebase session-death policy change)Failure-Class
Failure-Class: new
Registers
FC-agent-vm-public-health-unauth: public agent VM/healthmust not expose readiness metadata without the VM auth token. Evidence: #9261 / #7326.Manual steps (post-merge; current Python runtime)
This is a phase-1 health-auth rollout only. Keep public
ONE_TO_ONE_NAT/ public IP provisioning. Do not remove NAT, apply a public DENY firewall, or run the deferred phase-3 firewall script.PR #10686 retired the Node
agent.mjsand Rust agent runtime in favor of the Python Agent VM image. Do not publishagent.mjsor updateversion.txtas the rollout mechanism. Use the current versioned image/startup workflow on mergedmain.Safe order (callers before gate):
agent-proxyfrom mergedmainfirst. Dispatch.github/workflows/gcp_backend_agent_proxy.ymlwithenvironment=prod. The workflow checks outmain, builds/pushesagent-proxy, deploys it toprod-omi-gke, and waits for the GKE rollout to complete.AgentSyncService.swiftandAgentVMService.swiftchanges from this PR. Do not let VMs enforce the new health gate before this caller is available; otherwise desktop health checks receive401and may false-trigger DB re-upload paths..github/workflows/desktop_backend_prod.ymlis a combined desktop-backend production release: in addition to building/publishinggcr.io/based-hardware/agent-vm:<first-12-of-release-sha>andgs://based-hardware-agent/startup.sh, it deploys and probes a desktop-backend candidate, then routes 100% of production traffic and can roll back. Do not dispatch it solely to publish the VM image. Use it only after separately approving that combined desktop-backend release, with the exact mergedrelease_sha, normal release-eligibility proof,confirm=deploy-desktop-backend-prod, and a non-empty operatorreason. There is no dedicated VM-only publisher currently; create and approve that path before a VM-only rollout.curl -sS -i http://<vm-public-ip>:8080/healthreturns401and no readiness metadata.curl -sS -i -H "Authorization: Bearer <vmToken>" http://<vm-public-ip>:8080/healthreturns200with the expecteddatabaseReadyfield.agent-proxyGKE rollout, the VM runtime/image identity, and desktop provision → upload/sync plus chat viawss://agent.omi.me.401, or upload/sync/chat regresses. Do not change firewall or NAT state while investigating.Do not run
backend/scripts/apply-agent-vm-firewall.sh, remove public NAT, or use--livereachability against production until PR10c plus private reachability and the reserved Cloud NAT allowlist are proven.Test plan
cd backend && python3 -m pytest tests/unit/test_agent_vm_firewall_contract.py tests/unit/test_agent_vm_health_auth_contract.py tests/unit/test_agent_vm_protocol.py -v→ PR-specific backend contract tests passbash backend/scripts/apply-agent-vm-firewall.sh→ exit 1REFUSEDbash backend/scripts/agent-vm-reachability-check.sh→ passed (hermetic; no production--livecheck)/healthsends Bearer +?token=(AgentSyncBatchQueryTests)Merge with a regular merge (no squash). Do not auto-merge — coordinate the caller-before-gate deployment order above.