Skip to content

fix(studio): harden the image supply chain and pin one Node major - #2133

Merged
rdimitrov merged 2 commits into
mainfrom
fix/studio-image-supply-chain
Oct 6, 2026
Merged

rdimitrov merged 2 commits into
mainfrom
fix/studio-image-supply-chain

Conversation

@peppescg

@peppescg peppescg commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Hardens the Mecatl Studio image supply chain and puts Studio on a single Node major. The comparison point is the SEP cloud-ui release pipeline.

Route: Routine. There is no product behavior change, and the base image stays Chainguard as ADR 0351 decides (decision 6), so no ADR amendment is needed.

One Node major everywhere

  • apps/package.json engines (>=26 <27) is now the source of truth. .node-version, the builder stage (node:26-slim), the esbuild target (node26), @types/node, and the Chainguard runtime all match it.
  • Before this change, tests and the build ran Node 24, but the published image ran Node 26 (26.10.0 today). A Renovate digest bump (chore(deps): update studio #1955) moved it from 26.9.0 to 26.10.0 inside a lockfile-heavy group PR without anyone noticing.
  • Public Chainguard only serves latest, so its digest cannot be version-constrained. Two guards cover that:
    • The CI studio job rejects an image whose Node major falls outside engines.
    • Renovate opens a dedicated studio node runtime PR for that digest. It never proposes Node 27 for the builder image, .node-version, or @types/node.
  • Node 25+ differences fixed along the way:
    • Web Storage: Node 25+ ships a global Web Storage that shadows jsdom's localStorage, which broke 77 web tests. The web Vitest workers now run with --no-experimental-webstorage.
    • corepack: Node 25+ no longer bundles corepack, so the builder installs it explicitly ([email protected]).

Image

  • Code directory: the runtime now uses a root-owned /opt/studio.
    • The base image's /app is world-writable, so the server process could replace its own code.
    • WORKDIR alone was not enough: it creates the directory as the base image's user, 65532. The Dockerfile now switches to root for the copy steps.
  • FROM line: the runtime FROM now shows :latest@sha256:…, and the stale "Node v26.9.0" pin comment is replaced with the rule that governs it.

CI (studio job)

  • task studio:audit: pnpm audit --prod, which covers what the image ships.
  • Image validation: the job loads the built image (instead of build-only) and checks that:
    • the Node major is within engines;
    • the process is not root and its working directory is not writable;
    • there is no corepack, pnpm, or dev tooling in the image;
    • the image boots with its real entrypoint against the offline mecated --mock the integration step builds, using both listeners, and /api/v1/status reports reachable.
  • Grype: a scan that fails on fixable critical vulnerabilities, the same gate as the release job.

Release (publish-studio)

The order is now: push by digest (no tags) → Grype (critical, only-fixed, as in SEP) → cosign sign → SBOM attest → provenance → verify → tag. Details:

  • Verify step: cosign verify plus verify-attestation for both spdxjson and slsaprovenance1, against the exact identity release.yml@refs/tags/<VERSION>.
  • Tag step: :<VERSION> and :latest are applied only after verification, and the step then asserts that both tags resolve to the signed digest.
  • What this fixes: today the image is pushed with both tags before signing, so a failed signing step leaves an unsigned :latest live.
  • Alignment with sibling jobs: needs: [guard, validate-release-ref] and VERSION from needs.guard.outputs.version.
  • Removed branch: the BUILT != RUN_SHA branch is gone. The checkout assertion directly before it already makes it unreachable.
  • OCI labels: added version, licenses, description, and documentation.

Docs (user-docs/building/deployment/studio.md)

  • Verification commands: they now pin the release workflow at the tag. Previously --certificate-identity-regexp '^https://github.com/stacklok/mecatl/' accepted a signature from any workflow on any ref.
  • Deploying by digest: documented.
  • Kubernetes securityContext: documented as read-only root filesystem, non-root, no capabilities, and no privilege escalation.

Verification

All local runs used Node 26.10.0 and pnpm 12.4.2.

Studio gates

  • task studio:check: Biome, typecheck, generated-contracts check, server 171/171, web 567/567.
  • task studio:audit: no known vulnerabilities.
  • task studio:test:integration: 8/8.
  • task studio:browser: 42/42 Playwright journeys.

Image (task studio:image)

  • The image boots against a local mecated --mock and /api/v1/status reports reachable. Both / and /api/health return 200.
  • It also boots with --read-only --cap-drop ALL --security-opt no-new-privileges.
  • Inside the image: Node 26.10.0, uid 65532, /opt/studio not writable.
  • Negative check: the same permission check fails on the published v0.0.44 image (/app writable).
  • The local smoke used host.docker.internal plus a static token, because Docker Desktop on macOS has no host networking. The CI step uses --network host on Linux, the same as the existing Slack bot image validation.

Grype (--only-fixed --fail-on critical) passes on the new image. There are 4 fixable High findings, all in the npm that Chainguard bundles (/usr/lib/node_modules/npm, apk npm-12), not in Studio code. Newer Chainguard digests fix them, and the dedicated Renovate PR will bring them in.

Signing commands

  • cosign verify and verify-attestation (spdxjson, slsaprovenance1) with the exact tag identity pass against the published v0.0.44.
  • gh attestation verify --signer-workflow … --source-ref refs/tags/v0.0.44 passes, and a wrong --source-ref fails.

Tagging: docker buildx imagetools create from a single index keeps the digest. I checked this against a local registry with a multi-arch push-by-digest image, and the job also asserts it.

Repository checks

  • task lint:actions: actionlint is clean.
  • microvm-ci-release_test.sh fails on darwin-arm64 with "built-in microVM release defaults do not exactly match", identically on unmodified main. It is unrelated to this change.
  • renovate-config-validator --strict passes.
  • task lint passes.
  • task test:race passes everywhere except four microVM tests on darwin-arm64, which this PR does not touch (it changes no Go code):
    • microvmmanager TestDevelopmentRelease* (×2): "release bundle omitted the platform manifest".
    • gitexec TestRunInDirUsesDescriptorAndPassesArgumentsOpaquely.
    • environment/microvm TestForkOperationPinEndsBeforeChildOwnerLifetime (git branch: signal: killed under full-suite load).
    • The first three fail identically on unmodified main. The fork test passes in isolation on main.
    • Linux CI is the authority for these packages.
  • task docs and task site:build pass.

Notes for reviewers

  • Overlap with feat(studio): complete chat approvals, plan review, and Escape flow #1975: feat(studio): complete chat approvals, plan review, and Escape flow #1975 also edits the studio CI job (it moves the Playwright step after integration). Whichever PR lands second needs a trivial rebase.
  • Out of scope, follow-ups:
    • 4 high advisories in dev-only dependencies (js-yaml via @hey-api/openapi-ts, source-map-js via vitest/vite). pnpm audit --prod intentionally covers the shipped closure only.
    • The .ko.yaml chainguard/static digest has no Renovate manager (mecated/mecak8s images).
    • publish-slack-bot has the same "tags before signing" shape.
    • Releases v0.0.42–44 fail in resolve-brood-base (exec format error on the arm64 digest helper), which skips the mecated and mecatui images. The Studio image is unaffected.
  • Node 27 handling: when Chainguard latest moves to Node 27 (~April 2027), the Renovate PR turns red. Moving to 27 then means bumping engines on purpose, or changing the base.

🤖 Generated with Claude Code

Run Studio on a single Node major, set by apps/package.json engines
(>=26 <27): .node-version, the builder stage, the esbuild target,
@types/node, and the Chainguard runtime all agree. Node 25+ ships a
global Web Storage that shadows jsdom's, so the web Vitest workers run
with --no-experimental-webstorage, and the builder installs corepack
explicitly because Node 25+ no longer bundles it.

Public Chainguard only serves `latest`, so the runtime digest cannot be
version-constrained. The CI studio job now loads the built image and
fails when its Node major falls outside engines, when it runs as root or
can write its own code, or when it cannot boot against an offline
mecated --mock. Renovate reviews that digest in its own PR and never
proposes Node 27 for the builder, .node-version, or @types/node.

The runtime moves to a root-owned /opt/studio: the base image's /app is
world-writable, and WORKDIR inherits the base's non-root user.

publish-studio pushes by digest, scans with Grype (critical, fixable
only, as in SEP), signs, attests, verifies the signature and both
attestations against release.yml at the release tag, and only then tags
:<VERSION> and :latest, so a failed step can no longer leave an unsigned
:latest. CI runs the same Grype gate and a pnpm audit of the production
dependencies. The job also takes its version from the guard like its
siblings, drops a provenance branch the checkout assertion already makes
unreachable, and completes its OCI labels.

The Studio deployment guide verifies against the release workflow at the
pinned tag and documents deploying by digest with a read-only,
non-root, capability-free security context.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
shellcheck (SC2086) rejects the unquoted `set -- $want` that split the
engines range into its bounds. Read the lower and upper bound separately
instead; behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rdimitrov
rdimitrov merged commit 649b00f into main Oct 6, 2026
38 checks passed
@rdimitrov
rdimitrov deleted the fix/studio-image-supply-chain branch October 6, 2026 11:38
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 7, 2026
2 tasks
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.

3 participants