ci: seal.key from the seal broker for main and v* tags only; the website's PR code off the deploy runner #2429

Merged
HumanBean merged 1 commit from HumanBean/Longshot:seal-broker into main 2026-11-24 14:58:52 +00:00
Owner

Summary

Do not merge before the seal broker runs on the server (MagicBeanDev/Infra PR: MagicBeanDev/Infra#7). Once merged, release publish and the website deploy get seal.key from the broker, not from a mounted file. Without the broker they fail to unseal.

Why. This comes from the security review of #2286's CI. A label only routes a job. Anyone who can push a branch, or open a pull request (it runs its own copy of the workflows), could add a job with runs-on: deploy, mount /magicbean-secrets, and open RELEASE_SIGNING_KEY_SEALED or the org-wide PACKAGES_TOKEN_SEALED. website.yml also ran a PR's own npm ci / npm run build on deploy with seal.key mounted. forgejo-runner 13 has no filter by ref or event, and a workflow sets its own env, steps and container, so nothing on the runner can tell such a job from a real one.

What changed.

  • scripts/ci_secret.sh unseal fetches seal.key from the seal broker. The job sends the ID token Forgejo signs for it (enable-openid-connect: true, audience magicbean-seal-broker) over HTTPS with a pinned key (SEAL_BROKER_PIN). The broker hands the key only to these runs of an allowed repository:
    • push to main or to a v* tag;
    • schedule or workflow_dispatch on main;
    • pull_request_target from main's own workflow file.
  • release.yml publish: no volume; enable-openid-connect on that job only.
  • website.yml, the PR's code is off deploy:
    • deploy: main only. It builds, checks and deploys on deploy.
    • check: a PR's build and checks, on ubuntu-latest, with no secrets.
    • preview-build: pull_request_target, for same-repo PRs or a fork PR with the preview label. It builds the PR on ubuntu-latest, with no key and no ID token, and uploads dist/.
    • preview-upload: on deploy. It checks out main and uploads the PR's dist/ (files only) with main's wrangler, wrangler.jsonc and worker/index.ts.
  • .forgejo/actionlint.yaml accepts enable-openid-connect. docs/dev/reference/ci.md and releases.md match.

Read first: scripts/ci_secret.sh, then website.yml.

Companion PRs: LongshotLauncher MagicBeanDev/LongshotLauncher#267, Beanstalk MagicBeanDev/Beanstalk#146, Infra MagicBeanDev/Infra#7.

Testing

Tested: CI only; nothing the game runs changes. Not run anywhere yet: the broker isn't deployed, and no tests were run on this PC.

Still to test (once the broker is up and SEAL_BROKER_PIN is set):

  • The nightly after merging: Sign and publish gets the key and signs, expecting SHA256SUMS.sig as before (by hand).
  • A push to main touching website/: the deploy job deploys (by hand).
  • A same-repo PR touching website/: check, preview-build and preview-upload pass and the preview link is posted (by hand).
  • A test branch with a job on deploy that runs scripts/ci_secret.sh unseal: refused, with the broker's reason in the log (by hand).

Measurements

Nothing to measure: CI workflow and docs only.

Risks

  • Merged before the broker runs, or without SEAL_BROKER_PIN: nightlies and the website deploy fail at the unseal step. A revert is enough.
  • The broker's checks rest on Forgejo protecting main (no direct push) and the v* tags (a protected-tag rule). Forgejo 17's ref_protected claim is always false, so the broker can't check this itself.
  • Never turn on enable-openid-connect in a job that checks out PR code.
  • Website behaviour changes:
    • A same-repo PR is built twice (check, then preview-build).
    • A PR's change to the Worker (worker/index.ts) shows in its preview only once merged.
    • The job "Website on Cloudflare" now runs on main only: update any required status check that uses that name.
  • #2286's PACKAGES_TOKEN_SEALED job needs the same change: enable-openid-connect: true, SEAL_BROKER_PIN, and no volume.

Must happen first:

  1. The seal broker is up on the server (Infra PR, commit 2).
  2. The organization variable SEAL_BROKER_PIN is set.
  3. Branch protection on main and a protected-tag rule for v*.

After this merges (and the launcher's and Beanstalk's), Infra's commit 3 removes the /magicbean-secrets mount.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (CI only; runs once the broker is deployed)
  • mise run test passes (any failure that also fails on main is named). (not run on this PC; CI runs it)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary **Do not merge before the seal broker runs on the server** (MagicBeanDev/Infra PR: https://git.magicbean.dev/MagicBeanDev/Infra/pulls/7). Once merged, release publish and the website deploy get seal.key from the broker, not from a mounted file. Without the broker they fail to unseal. **Why.** This comes from the security review of [#2286](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2286)'s CI. A label only routes a job. Anyone who can push a branch, or open a pull request (it runs its own copy of the workflows), could add a job with `runs-on: deploy`, mount `/magicbean-secrets`, and open `RELEASE_SIGNING_KEY_SEALED` or the org-wide `PACKAGES_TOKEN_SEALED`. `website.yml` also ran a PR's own `npm ci` / `npm run build` on `deploy` with seal.key mounted. forgejo-runner 13 has no filter by ref or event, and a workflow sets its own env, steps and container, so nothing on the runner can tell such a job from a real one. **What changed.** - `scripts/ci_secret.sh unseal` fetches seal.key from the seal broker. The job sends the ID token Forgejo signs for it (`enable-openid-connect: true`, audience `magicbean-seal-broker`) over HTTPS with a pinned key (`SEAL_BROKER_PIN`). The broker hands the key only to these runs of an allowed repository: - `push` to main or to a `v*` tag; - `schedule` or `workflow_dispatch` on main; - `pull_request_target` from main's own workflow file. - `release.yml` publish: no volume; `enable-openid-connect` on that job only. - `website.yml`, the PR's code is off `deploy`: - `deploy`: main only. It builds, checks and deploys on `deploy`. - `check`: a PR's build and checks, on `ubuntu-latest`, with no secrets. - `preview-build`: `pull_request_target`, for same-repo PRs or a fork PR with the `preview` label. It builds the PR on `ubuntu-latest`, with no key and no ID token, and uploads `dist/`. - `preview-upload`: on `deploy`. It checks out main and uploads the PR's `dist/` (files only) with main's wrangler, `wrangler.jsonc` and `worker/index.ts`. - `.forgejo/actionlint.yaml` accepts `enable-openid-connect`. `docs/dev/reference/ci.md` and `releases.md` match. Read first: `scripts/ci_secret.sh`, then `website.yml`. Companion PRs: LongshotLauncher https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/267, Beanstalk https://git.magicbean.dev/MagicBeanDev/Beanstalk/pulls/146, Infra https://git.magicbean.dev/MagicBeanDev/Infra/pulls/7. ## Testing **Tested:** CI only; nothing the game runs changes. Not run anywhere yet: the broker isn't deployed, and no tests were run on this PC. **Still to test** (once the broker is up and `SEAL_BROKER_PIN` is set): - The nightly after merging: *Sign and publish* gets the key and signs, expecting `SHA256SUMS.sig` as before (by hand). - A push to main touching `website/`: the deploy job deploys (by hand). - A same-repo PR touching `website/`: `check`, `preview-build` and `preview-upload` pass and the preview link is posted (by hand). - A test branch with a job on `deploy` that runs `scripts/ci_secret.sh unseal`: refused, with the broker's reason in the log (by hand). ## Measurements Nothing to measure: CI workflow and docs only. ## Risks - Merged before the broker runs, or without `SEAL_BROKER_PIN`: nightlies and the website deploy fail at the unseal step. A revert is enough. - The broker's checks rest on Forgejo protecting `main` (no direct push) and the `v*` tags (a protected-tag rule). Forgejo 17's `ref_protected` claim is always false, so the broker can't check this itself. - Never turn on `enable-openid-connect` in a job that checks out PR code. - Website behaviour changes: - A same-repo PR is built twice (`check`, then `preview-build`). - A PR's change to the Worker (`worker/index.ts`) shows in its preview only once merged. - The job "Website on Cloudflare" now runs on main only: update any required status check that uses that name. - [#2286](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2286)'s `PACKAGES_TOKEN_SEALED` job needs the same change: `enable-openid-connect: true`, `SEAL_BROKER_PIN`, and no volume. **Must happen first:** 1. The seal broker is up on the server (Infra PR, commit 2). 2. The organization variable `SEAL_BROKER_PIN` is set. 3. Branch protection on `main` and a protected-tag rule for `v*`. After this merges (and the launcher's and Beanstalk's), Infra's commit 3 removes the `/magicbean-secrets` mount. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (CI only; runs once the broker is deployed) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (not run on this PC; CI runs it) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ci: seal.key from the seal broker for main and v* tags only; the website's PR code off the deploy runner
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website preview, upload (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
Website / Website preview, build (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 12s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request) Failing after 53s
CI / Website build and checks (pull_request) Failing after 53s
PR description / Description follows the template (pull_request_target) Failing after 8s
b4bfe9d546
A label only routes a job, so a workflow on any branch (or a pull request's own copy) could ask
for runs-on: deploy, mount /magicbean-secrets and open the release signing key. The key now comes
from the seal broker (MagicBeanDev/Infra), which checks the ID token Forgejo signs for the job:
push to main or a v* tag, schedule or workflow_dispatch on main, pull_request_target for the
website's preview upload.

- scripts/ci_secret.sh unseal fetches seal.key from the broker (enable-openid-connect,
  SEAL_BROKER_PIN) instead of reading the mounted file.
- release.yml publish: no volume, enable-openid-connect on that job only.
- website.yml: main's deploy job alone builds and deploys on deploy; a PR is built and checked on
  ubuntu-latest (check), and its preview is preview-build (the PR's code, ubuntu-latest, no key)
  then preview-upload (deploy, main's code and wrangler, the PR's dist/ as files only).
- docs/dev/reference/ci.md, releases.md to match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SkKpc592GgxftLP8o
Member

Possibly related, for context:

  • PR #2123 ci: the release and deploy jobs run only on the server's runner, their secrets sealed with a key only it has — Earlier sealed-secret setup this changes from mounted key to broker
Possibly related, for context: - PR #2123 ci: the release and deploy jobs run only on the server's runner, their secrets sealed with a key only it has — Earlier sealed-secret setup this changes from mounted key to broker
HumanBean changed title from WIP: ci: seal.key from the seal broker for main and v* tags only; the website's PR code off the deploy runner to ci: seal.key from the seal broker for main and v* tags only; the website's PR code off the deploy runner 2026-11-24 14:58:40 +00:00
HumanBean deleted branch seal-broker 2026-11-24 14:58:52 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2429
No description provided.