Ready

mirendev/runtime#1446

I think this is still ready for human review. I'm not recommending it skip one, for the same reason as before: it's a security boundary that runs across the coordinator, the runner, config pinning and app deletion.

What changed: the branch is now a single squashed commit. The code is the same as in the version I last reviewed, including the server, ownership, materialize, pin, remote-resolver, cluster-backend, secretpin, app-delete and build-saga files. The only content change is in docs/docs/secrets.md.

That doc change is a real fix. The note used to tell users to upgrade runners first, but that isn't the order an upgrade happens in. It now describes the actual order: the server upgrades first, then distributed runners one at a time. It also says a runner still on the old version can't start sandboxes that use an owned secret until it catches up, and tells users to wait for the upgrade to finish before giving secrets an app. The PR description now says the same.

Earlier questions:

I found no new defects. The race between a secret write and an app delete is tracked separately, as the description says.


Verdict: ready

Data

{
  "owner": "mirendev",
  "repo": "runtime",
  "number": 1446,
  "verdict": "ready",
  "event": "comment",
  "summary": "I think this is still ready for human review. I'm not recommending it skip one, for the same reason as before: it's a security boundary that runs across the coordinator, the runner, config pinning and app deletion.\n\n**What changed:** the branch is now a single squashed commit. The code is the same as in the version I last reviewed, including the server, ownership, materialize, pin, remote-resolver, cluster-backend, secretpin, app-delete and build-saga files. The only content change is in `docs/docs/secrets.md`.\n\nThat doc change is a real fix. The note used to tell users to upgrade runners first, but that isn't the order an upgrade happens in. It now describes the actual order: the server upgrades first, then distributed runners one at a time. It also says a runner still on the old version can't start sandboxes that use an owned secret until it catches up, and tells users to wait for the upgrade to finish before giving secrets an app. The PR description now says the same.\n\n**Earlier questions:**\n- **Rollout order:** settled. You've accepted that old runners fail closed on owned secrets during the upgrade window, and the docs now say so accurately. I'm dropping it.\n- **Whether `Spec.Version` can be trusted to identify a sandbox's app:** still open, and still needs a human reviewer. It's what decides which app a sandbox belongs to when the runner checks ownership (the app callback passed to `MaterializeEnv`, `controllers/sandbox/sandbox.go:2564`).\n\nI found no new defects. The race between a secret write and an app delete is tracked separately, as the description says.",
  "posted_to_pr": true,
  "head_sha": "7573e61894589f0779b196fc2ef81138d340c6ca"
}
Previous revisions (2)
Revision 2 · 3d ago

mirendev/runtime#1446

I think this is ready for human review. I'm not recommending it skip one: it's security-sensitive, it touches the coordinator, the runner, app deletion and the RPC contract, and two of my earlier questions still need a reviewer.

What changed: the wire-contract point from my last review is fixed. Secrets.Resolve now takes app_id, and its result returns owner_id (api/secret/rpc.yml:160-173). Set.app and SecretInfo.app stay as names, and their docs say so. Every caller I traced was updated:

  • the generated client and args
  • servers/secret/server.go:418-428, which reads args.AppId() and writes SetOwnerId
  • pkg/secret/remote/remote.go, which reads res.OwnerId()
  • the ownership tests

The CBOR key is still index 2, so only the field's name changes, not its wire format. A caller who passes a name where an id belongs now has the field name pointing out the mistake.

Still needs a reviewer: two questions from last time, which this push doesn't touch:

  1. Whether Spec.Version can be trusted to identify a sandbox's app.
  2. Whether a doc note is enough to make sure runners are upgraded before the coordinator.

I didn't find any new defects. The app-delete race (a secret created for an app while that app is being deleted) is still open, and it's already tracked as MIR-2248, as the description says.

Replies to existing threads

Posted to the PR's comment threads when you submit.

  • (reply) I see the rename landed: Resolve now takes app_id and returns owner_id, and the server, the remote resolver, and the generated client all use the new names. The CBOR index didn't change, so the wire format is the same. Of the two options I suggested, this is the one I'd have picked, and it settles the ambiguity as far as I'm concerned. I asked a human reviewer to make this call, though, so I'm leaving the thread for them to close.

Verdict: ready

Revision 1 · 3d ago

mirendev/runtime#1446

I think this is ready for human review. I'm not recommending it skip one: it's security-sensitive and touches the coordinator, the runner, the RPC contract, and app deletion.

What I found holds up. An owned secret's plaintext is refused to any other app at both places it can come into existence:

  • Local runner: MaterializeEnv → CheckOwner. The sandbox's app comes from sandboxAppID, which reads it from Spec.Version.
  • Remote runner: Server.Resolve refuses unless args.App() == val.Owner, and the runner checks the owner again on the value that comes back.

Both paths fail closed: a failed app lookup, or a runner that names no app, gets no owned secrets. All six ConfigVersion writers go through coreutil.PinSecrets with the config's app. The build saga passes string(appRec.ID), so the build-time CheckOwner compares ids with ids. Cert-authenticated callers return false from CompositeAuthorizer.UsesLogicalAuthorization, so runners aren't narrowed and Cloud RBAC won't block distributed runners from resolving owned secrets. In ensureSecret, switching from CreateOrUpdate to Create plus read-back is what makes the first owner stick when two writers race. And the Authorize callback inside PutOwned checks the row it is actually about to write, not an earlier lookup.

Where a reviewer's judgment matters most:

  1. Trust in Spec.Version. The runner decides which app a sandbox belongs to from its version. That's only as strong as the guarantee that nobody can create a sandbox pointing at another app's version. I didn't find a user-facing path that allows it: deploy-time env carries no Backend, and runs don't take env overrides. But this is now load-bearing for secret isolation and deserves an explicit look.
  2. Rollout order. The docs say to upgrade runners first, but nothing enforces it. A pre-ownership runner talking to a new coordinator will fail to start any sandbox that references an owned secret: Resolve returns "a runner that predates secret ownership cannot". Today that only happens after someone runs secret set --app. Once MIR-2144 starts creating owned secrets automatically it will be routine, so whether a doc note is enough is a release decision.
  3. Wire contract (inline note). Secrets.Set's app takes an app name, while Secrets.Resolve's app takes an entity id.

A smaller point: ListVersions returns unauthorized for another app's secret but not-found for a path that doesn't exist, so a bound caller can tell which paths exist. That's probably acceptable because paths aren't secret, but it's worth knowing.

Tests cover the cases I'd want: cross-app pin refusal, the task-env and =-key smuggling cases, the coordinator refusing a runner that names no app or the wrong one, owner-on-create races, and app deletion removing owned secrets and their versions. I didn't run them.

Inline comments

  • api/secret/rpc.yml:160 — Set.app (above) is an app name, but this Resolve.app is an app id (app/shop), and Resolve.owner in the results is an id too. Both are documented, but once this field ships it's permanent. A future caller that passes a name here gets ErrOwnedByOtherApp instead of something that points at the mistake. Could a reviewer decide whether to use the same form for both fields, or to name this one app_id, before it goes out?

Verdict: ready