Skip to content

Carry secrets in a typed field on the sandbox spec - #1459

Open
phinze wants to merge 1 commit into
phinze/mir-2144-sensitive-env-secretsfrom
phinze/mir-2250-dual-write
Open

phinze wants to merge 1 commit into
phinze/mir-2144-sensitive-env-secretsfrom
phinze/mir-2250-dual-write

Conversation

@phinze

@phinze phinze commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Secrets reach a container as env entries starting with miren+secret://, and the runner resolves anything with that prefix. So "is this a secret?" comes down to pattern-matching a string that lots of things write, and every producer has to be stopped from writing a literal that happens to look like one.

The sandbox spec now carries secrets in their own typed field. A runner that sees the secrets_typed marker resolves only that field and treats env as literal. This release still writes the sentinel too, so older runners keep working. Dropping the sentinel, and the check that rejects literals posing as references, waits for a release that requires runners from this one or newer.

The upgrade itself doesn't roll anything. When the launcher compares specs, it reads an old pool's sentinels back as the secrets they name, so pools from before the upgrade keep running until the app changes for some other reason.

Stacked on #1458.

Part of MIR-2250

@phinze
phinze added this pull request to stack #1460 November 30, 2026 20:44
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze force-pushed the phinze/mir-2250-dual-write branch from 128108f to 8ca0bb2 Compare November 30, 2026 23:48
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze force-pushed the phinze/mir-2250-dual-write branch from 8ca0bb2 to f8f82f4 Compare December 1, 2026 04:39
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze force-pushed the phinze/mir-2250-dual-write branch from f8f82f4 to e461c11 Compare December 1, 2026 04:57
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze force-pushed the phinze/mir-2250-dual-write branch from e461c11 to a7a0fa1 Compare December 1, 2026 14:41
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze force-pushed the phinze/mir-2250-dual-write branch from a7a0fa1 to 2522dcc Compare December 1, 2026 15:00
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze force-pushed the phinze/mir-2250-dual-write branch from 2522dcc to 0e4cee4 Compare December 1, 2026 16:05
miren-code-agent[bot]

This comment was marked as outdated.

@phinze
phinze marked this pull request as ready for review December 1, 2026 16:24
@phinze
phinze requested a review from a team as a code owner December 1, 2026 16:24

@evanphx evanphx 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.

Makes sense! Better than the pattern matching.

A secret has reached a container as an env entry whose value starts with
miren+secret://, and the runner resolves anything matching that prefix.
So whether a value is a secret is decided by pattern-matching a string
that many sources write, and every producer has to be stopped from
writing a literal that looks like a reference.

The container spec now has a secret field, separate from env, naming
each secret's backend and reference and the variable it projects into.
appspec.Build fills it for every backend-sourced variable and sets
secrets_typed. A runner that sees the marker resolves only the typed
field and treats env as literal, so a value that merely looks like a
sentinel is handed to the app verbatim.

This release still writes the sentinel too, so a runner from before the
typed field keeps working; it ignores the new attrs. Dropping the
sentinel waits for a release that requires runners from this one or
newer, and the rejection of literals posing as references at pin time
stays until then, since specs built before this change still rely on it.

specsMatch compares the typed secrets, so a rotation still rolls a pool.
For a pool created before the upgrade it reads the sentinels in env back
as the secrets they name. The launcher rebuilds every app's spec each
minute, so without that, every app with a secret would replace its
sandboxes (and drain any disk service first) right after the coordinator
upgrade. Instead an old pool keeps running until the app changes for
some other reason. The marker alone is not compared, for the same
reason: with equal secrets the runner materializes the same environment
either way.

Part of MIR-2250.
@phinze
phinze force-pushed the phinze/mir-2250-dual-write branch from 0e4cee4 to 6c6785e Compare December 3, 2026 16:44

@miren-code-agent miren-code-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🍪 biscuit: ✅ ready to merge — auto-review, non-blocking

Approval recommended, not submitted: this repository is not enabled for autonomous approvals. This review is a comment, not a GitHub approval.

Since 0e4cee4, the only change in this layer is that it no longer touches pkg/nodecaps/nodecaps.go. At 0e4cee4 this PR added a SecretTyped capability there. #1458's new head removes the nodecaps package entirely, so the file doesn't exist at 6c6785e and the capability is gone with it. Nothing in this PR ever read that capability. The transition depends on dual-writing: appspec.Build still writes every backend-sourced variable twice, once as a typed entry and once as a sentinel. The ticket accepts either a dual-write release or a capability check, so losing the capability doesn't leave a gap here. The one consequence is for the later release that stops writing sentinels. It won't be able to ask the cluster whether every runner understands the typed field, so it has to rely on a minimum runner version. The PR description already says that's the plan.

The rest of the layer is what I reviewed last time:

  • the covered-key and legacy branches in materialize.go
  • the ExtraEnv trimming in Build
  • effectiveSecrets/secretsEqual in specsMatch
  • containerEnv in the sandbox controller

buildSubContainerSpec is still the only non-test caller in controllers/ that materializes env, and it calls MaterializeContainerEnv. Nobody has posted a new comment or reply, and both of my threads are still resolved.

I'd held back from recommending approval for two reasons, and both are now settled. I wanted a human to read the transition logic, and evanphx approved at 0e4cee4, where that logic is identical to this head. #1458 is also no longer a draft. The only change since that approval removes an unused constant, so I'm recommending approval of this layer. It should still merge after #1458, since it's stacked on it.


🍪 full review note · reviewed at 6c6785e

This branch has not been deployed

No deployments
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