Skip to content

feat(mecak8s): match the execution allowlist on issuer and subject - #2544

Merged
ChrisJBurns merged 9 commits into
mainfrom
feat/execution-allowlist-issuer-subject
Oct 27, 2026
Merged

ChrisJBurns merged 9 commits into
mainfrom
feat/execution-allowlist-issuer-subject

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #2521.

The mecak8s execution allowlist matched a caller's subject alone. With --oidc-owner-identity=sub_id, the caller's issuer comes from the token's sub_id claim, so a user from another IdP with an allowlisted sub would have been allowed. The allowlist now names principals by issuer and subject, matched exactly with session.Principal.SameIdentity, for both template listing (ExecutionTemplateAllowed) and owner binding and reattachment (ExecutionOwnerAllowed).

  • New surface: repeatable --execution-allowed-principal=ISSUER|SUBJECT, Helm execution.allowedPrincipals: [{issuer, subject}]. The entry splits at the first |. An issuer URL can't contain |, but a subject can (for example Auth0's auth0|123). Empty, padded, control-character and duplicate entries are rejected at startup, and the chart rejects the same at render time.
  • Issuer form: an issuer must be an https:// or http:// URL with a host and no credentials, spaces, query or fragment. mecak8s and the chart both enforce this, so a typo such as idp.example fails at startup instead of matching nobody. It is validated but never normalized: entries still match byte-exactly. Plain HTTP is accepted because mecak8s never contacts the allowlist issuer, and a local IdP stand-in such as Dex behind AS-1 may be served over HTTP. Subjects may contain internal spaces (team carol) in both the flag and the chart.
  • Existing form: --execution-allowed-subjects / execution.allowedSubjects now resolves to --oidc-issuer plus each subject. The validator already pins iss to that issuer byte-exactly, so admission is unchanged while --oidc-owner-identity is off. With it on, mecak8s refuses subject-only entries at startup, and the chart refuses them at render time. Setting both forms is refused too. The subject-only form is deprecated in the flag help, values comments and docs.
  • Scope: flag and Helm value only, no settings.yaml key. That matches how the rest of the execution client is configured.
  • Docs: caller-identity.md and the mecak8s native-execution guide describe the new form and the upgrade path. server-cli.md is regenerated.

API compatibility

  • Assessment: no wire API change. No proto, engine/session or internal/adapter/server change. The callback signatures in app.Config are unchanged; only the operator policy behind them changes.
  • Major or feature changes: none.
  • Configuration compatibility: a mecak8s flag and Helm value are added. The existing flag and value stay valid while --oidc-owner-identity is off.
  • Upgrade implications:
    • Owner identity off: no change needed. Moving to allowedPrincipals with issuer: <oidc.issuer> is recommended.
    • Owner identity sub_id on: replace allowedSubjects with allowedPrincipals entries naming the sub_id identity, which is the company IdP's issuer and subject. This combination previously matched on subject alone. It only shipped with feat(authn): own sessions by the sign-in's sub_id identity #2497, and the real AS-1 isn't hosted yet (Host AS-1 in mecak8s #2490).

Test plan

  • go test -race ./cmd/mecak8s/ ./deploy/helm/mecak8s/ passes. The new tests cover:

    • issuer and subject matching with owner identity on and off, including a same subject with another issuer, a trailing-slash issuer, and a | inside the subject;
    • mapping the existing subject form to --oidc-issuer;
    • startup refusals;
    • chart rendering and refusals.
  • task lint: root module clean. The one finding is pre-existing, environment/microvm/launch_ownership_darwin.go:754 (gosec G703), which this change doesn't touch.

  • task docs:server-cli:check, matlatl strict (0 findings on a clean checkout of this branch), task site:build and go run ./cmd/mecademo pass.

  • task test:race: cmd/mecak8s passes. A few tests in packages this change doesn't touch fail locally on macOS:

    • These fail the same way on a clean origin/main worktree:
      • cmd/mecatui TestStartupCompatibilityEmbeddedRejected
      • cmd/mecatui TestConnectUsesSavedServerCAForLazyTLSRPC
      • cmd/mecated TestMecatedCLICompositionValidatesMicroVMDefaultAfterReadiness
    • internal/adapter/microvmmanager TestDefaultOperationsStartScrubsDaemonEnvironmentAndDetachesFromRequest fails only in the main checkout. It passes in a fresh worktree of this branch.

    CI is the reference run for these.

Notes

Add --execution-allowed-principal=ISSUER|SUBJECT (Helm
execution.allowedPrincipals) so execution template listing and owner
binding admit a caller only when both its issuer and subject match.
--execution-allowed-subjects keeps working as subjects of --oidc-issuer
while --oidc-owner-identity is off, is refused with it on and alongside
the new form, and is deprecated.

Closes #2521

Co-authored-by: Mecatl <[email protected]>
…ubjects

Refuse allowlist issuers that are not an https:// or http:// URL with a
host and no credentials, spaces, query, or fragment, at startup and at
chart render time, so a typo fails instead of matching nobody. Plain
HTTP stays valid because mecak8s never contacts the issuer. Let the
chart accept subjects with internal spaces, as the flag already does.

Co-authored-by: Mecatl <[email protected]>
@ChrisJBurns
ChrisJBurns requested a review from jhrozek October 26, 2026 21:18
ChrisJBurns and others added 3 commits October 27, 2026 00:33
Helm 3 reports the schema failure as execution.allowedPrincipals and the
Helm in CI as /execution/allowedPrincipals; assert on the field name.

Co-authored-by: Mecatl <[email protected]>

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

Approving. One non-blocking item:

The Helm chart accepts two issuer forms that the binary refuses: a malformed percent escape in the path (for example https://idp.example/%zz) and a brace in the host (for example https://idp{x}.example). helm template renders both, and the binary then fails at startup, so the pod crash-loops instead of failing at render time. Suggest tightening the chart issuer regex in deploy/helm/mecak8s/templates/_helpers.tpl to match what url.Parse accepts, and adding those two cases to TestExecutionAllowedPrincipalsChart.

The chart's issuer check accepted a malformed percent escape in the path
and host characters Go's url.Parse rejects ({, }, \, ^, `, %), so the
chart rendered values that crash-looped the pod. Match url.Parse there.

Co-authored-by: Mecatl <[email protected]>
@ChrisJBurns
ChrisJBurns merged commit 05911d8 into main Oct 27, 2026
44 of 45 checks passed
@ChrisJBurns
ChrisJBurns deleted the feat/execution-allowlist-issuer-subject branch October 27, 2026 17:13
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Match the execution allowlist on issuer and subject

2 participants