ci: scope the image push credential to people who may read it #13

Closed
opened 2026-10-25 18:17:54 +00:00 by Claude · 5 comments
Owner

Problem

PACKAGE_PUSH_USER and PACKAGE_PUSH_TOKEN are org-level Actions secrets. Per Gitea's source (GetSecretsOfTask) the only gate is that fork pull requests get no secrets. Branch name and protection are not considered, jobs.<id>.environment is ignored, and there is no protected-branch scoping. So:

  • Anyone who can push a branch to this repo can edit lint.yml/image.yml, or add a workflow, and read the token (the if: guard in image.yml is not a boundary, because the branch controls the file).
  • Every other repo in the mortis org can read the same secrets.
  • The job token (GITEA_TOKEN) is refused with 401 for package writes (run 2237). Gitea's package code has // TODO: ActionUser permission check, so the job-token-first probe and permissions: packages: write are dead weight (inferred from source and docs, not reproduced).

Mitigation today: consumers pin image:<version>@sha256:<digest>, so a tag push cannot change what CI runs without a reviewed pin edit. Residual risk is registry pollution/deletion and reuse of the token. Today only the operator and the Claude user can push.

Options (operator chooses; UI work is the operator's)

  1. Strongest: build the images in a separate private repo (e.g. mortis/kamino-images) where only the operator has write access, and keep the secrets there. Gitea has no other way to separate a secret from branch pushers.
  2. Minimum: replace the org secrets with repo secrets of mortis/kamino; re-issue the PAT with write:package only (bot member of a team with packages-write only); restrict branch-push access; optionally move the images to their own org.

Also: enable "Block merge if pull request is out of date" if this Gitea has it (lint tests the PR head, not the merge with main).

Prototype (validated locally, not merged)

A local prototype patch (757 lines): image.yml with the job-token path and permissions: removed, a single PAT probe that fails fast, corrected header comments, a hardened digest scrape (every Pushed <image>@sha256: line must carry the same digest). actionlint/yamllint --strict pass; the real kaniko/registry path was not run.

Acceptance

  • Operator decision recorded (option 1 or 2).
  • Org secrets deleted, new secrets created in the chosen scope, PAT limited to write:package.
  • image.yml and CLAUDE.md/CONTRIBUTING.md describe the PAT-only model.
  • Note: merging an image.yml change rebuilds both images under unchanged versions (sha-*/latest only). Do not paste a new pin from that build.

🤖 Generated with Claude Code

## Problem `PACKAGE_PUSH_USER` and `PACKAGE_PUSH_TOKEN` are **org-level** Actions secrets. Per Gitea's source (`GetSecretsOfTask`) the only gate is that fork pull requests get no secrets. Branch name and protection are not considered, `jobs.<id>.environment` is ignored, and there is no protected-branch scoping. So: - Anyone who can push a branch to this repo can edit `lint.yml`/`image.yml`, or add a workflow, and read the token (the `if:` guard in `image.yml` is not a boundary, because the branch controls the file). - Every other repo in the `mortis` org can read the same secrets. - The job token (`GITEA_TOKEN`) is refused with 401 for package writes (run 2237). Gitea's package code has `// TODO: ActionUser permission check`, so the job-token-first probe and `permissions: packages: write` are dead weight (inferred from source and docs, not reproduced). Mitigation today: consumers pin `image:<version>@sha256:<digest>`, so a tag push cannot change what CI runs without a reviewed pin edit. Residual risk is registry pollution/deletion and reuse of the token. Today only the operator and the `Claude` user can push. ## Options (operator chooses; UI work is the operator's) 1. **Strongest:** build the images in a separate private repo (e.g. `mortis/kamino-images`) where only the operator has write access, and keep the secrets there. Gitea has no other way to separate a secret from branch pushers. 2. **Minimum:** replace the org secrets with repo secrets of `mortis/kamino`; re-issue the PAT with `write:package` only (bot member of a team with packages-write only); restrict branch-push access; optionally move the images to their own org. Also: enable "Block merge if pull request is out of date" if this Gitea has it (lint tests the PR head, not the merge with `main`). ## Prototype (validated locally, not merged) A local prototype patch (757 lines): `image.yml` with the job-token path and `permissions:` removed, a single PAT probe that fails fast, corrected header comments, a hardened digest scrape (every `Pushed <image>@sha256:` line must carry the same digest). `actionlint`/`yamllint --strict` pass; the real kaniko/registry path was not run. ## Acceptance - [ ] Operator decision recorded (option 1 or 2). - [ ] Org secrets deleted, new secrets created in the chosen scope, PAT limited to `write:package`. - [ ] `image.yml` and `CLAUDE.md`/`CONTRIBUTING.md` describe the PAT-only model. - [ ] Note: merging an `image.yml` change rebuilds both images under unchanged versions (`sha-*`/`latest` only). Do not paste a new pin from that build. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Corrections after an independent review of this issue

The "Prototype" section understates the patch. The prototype patch (757 lines) is not an image.yml change: it bundles the content of PRs #14 to #18 as well, and is stale against them. Do not apply it. Only the image.yml credential part belongs to this issue:

  • image.yml: job-token path and permissions: packages: write removed, single PAT probe, digest scrape that requires every Pushed <image>@sha256: line to agree (this issue).
  • Comment/header changes (partly #14), concurrency (#17), tarball check and build_ignore (#18), version/pin checks (#16, whose check_image_versions.py was later fixed in that PR for COPY forms; the patch has the older version), dev-setup.sh (#15).
  • It has no changelog fragments and does not edit CLAUDE.md/CONTRIBUTING.md, which the acceptance list requires. #14 edits the same image.yml header and credential comments, so the credential change must be rebased on #14 (merge #14 first).

Risk in the prototype: the digest scrape now matches Pushed ${image}@sha256:... for this image only. If the kaniko fork logs the image string differently (another registry spelling), pushed=0 and the job fails after a successful push. The old scrape matched any Pushed *@sha256:. The kaniko path was not run.

Missing from the issue:

  • Order of operations: create the repo secrets before deleting the org ones, or the next image build breaks.
  • Rotation/rollback: the current PAT should be treated as exposed to anyone with branch-push access and rotated when the scope changes.
  • Who creates the bot user/team and which team scope write:package needs.
  • The option of keeping the job-token probe (#14 still documents it as tried first); the 401 cause is inferred from Gitea source and docs, not reproduced.
  • Still unverified: run 2237 and the Gitea GetSecretsOfTask / package-permission claims could not be checked from the repo.

Verified: image.yml on main does try the job token first (~l.182) with the PAT fallback (~l.186-206), permissions: packages: write is at l.41-43, and the if: guard (l.52-55) is not a boundary.

🤖 Generated with Claude Code

## Corrections after an independent review of this issue **The "Prototype" section understates the patch.** The prototype patch (757 lines) is not an `image.yml` change: it bundles the content of PRs #14 to #18 as well, and is **stale against them**. Do not apply it. Only the `image.yml` credential part belongs to this issue: - `image.yml`: job-token path and `permissions: packages: write` removed, single PAT probe, digest scrape that requires every `Pushed <image>@sha256:` line to agree (this issue). - Comment/header changes (partly #14), concurrency (#17), tarball check and `build_ignore` (#18), version/pin checks (#16, whose `check_image_versions.py` was later fixed in that PR for COPY forms; the patch has the older version), `dev-setup.sh` (#15). - It has no changelog fragments and does not edit `CLAUDE.md`/`CONTRIBUTING.md`, which the acceptance list requires. #14 edits the same `image.yml` header and credential comments, so the credential change must be rebased on #14 (merge #14 first). **Risk in the prototype:** the digest scrape now matches `Pushed ${image}@sha256:...` for this image only. If the kaniko fork logs the image string differently (another registry spelling), `pushed=0` and the job fails after a successful push. The old scrape matched any `Pushed *@sha256:`. The kaniko path was not run. **Missing from the issue:** - Order of operations: create the repo secrets *before* deleting the org ones, or the next image build breaks. - Rotation/rollback: the current PAT should be treated as exposed to anyone with branch-push access and rotated when the scope changes. - Who creates the bot user/team and which team scope `write:package` needs. - The option of keeping the job-token probe (#14 still documents it as tried first); the 401 cause is inferred from Gitea source and docs, not reproduced. - Still unverified: run 2237 and the Gitea `GetSecretsOfTask` / package-permission claims could not be checked from the repo. Verified: `image.yml` on `main` does try the job token first (~l.182) with the PAT fallback (~l.186-206), `permissions: packages: write` is at l.41-43, and the `if:` guard (l.52-55) is not a boundary. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Status 2026-11-09: repo is public, residual risk accepted for now

The repo is public. Facts that bear on this issue:

  • Fork pull requests get no Actions secrets (the GetSecretsOfTask rule this issue rests on), so the org-level PACKAGE_PUSH_* secrets are not exposed to a fork's workflow.
  • Gitea 28.0.0 has no setting that turns fork pull requests off or gates their workflows (token-permissions page and configuration reference checked today). The only levers are global and would also stop this repo's own CI.
  • Registration is closed (confirmed on the live instance by the operator), so only accounts the operator creates can fork or push a branch. Today that is the operator and the Claude user.
  • The runner is scoped to the mortis org, capacity 1.

So the exposure described above is still "anyone who can push a branch", and publishing the repo did not widen that population. The org-wide secret scope is unchanged: any mortis repo workflow can read it. The decision in this issue (option 1 or 2) stays open and is the proper fix. Until then the residual risk is accepted.

Opening registration, adding a collaborator with write access, or adding another repo to the mortis org each re-opens this question first.

🤖 Generated with Claude Code

## Status 2026-11-09: repo is public, residual risk accepted for now The repo is public. Facts that bear on this issue: - Fork pull requests get no Actions secrets (the `GetSecretsOfTask` rule this issue rests on), so the org-level `PACKAGE_PUSH_*` secrets are not exposed to a fork's workflow. - Gitea 28.0.0 has no setting that turns fork pull requests off or gates their workflows (token-permissions page and configuration reference checked today). The only levers are global and would also stop this repo's own CI. - Registration is closed (confirmed on the live instance by the operator), so only accounts the operator creates can fork or push a branch. Today that is the operator and the `Claude` user. - The runner is scoped to the `mortis` org, capacity 1. So the exposure described above is still "anyone who can push a branch", and publishing the repo did not widen that population. The org-wide secret scope is unchanged: any `mortis` repo workflow can read it. The decision in this issue (option 1 or 2) stays open and is the proper fix. Until then the residual risk is accepted. Opening registration, adding a collaborator with write access, or adding another repo to the `mortis` org each re-opens this question first. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Review of the map (2026-11-17).

Review of the map (2026-11-17). - The choice this issue asks for was made in pieces by the map: a packages-only push bot ([Recommended repository settings and branch protection](https://git.rkdr.net/Mortis/Kamino/issues/179), applied by [chore: apply the recommended repository settings, account permissions and branch protection](https://git.rkdr.net/Mortis/Kamino/issues/192)) and repository secrets once a second repository joins ([Code-owner approval against Renovate automerge, and where secrets live](https://git.rkdr.net/Mortis/Kamino/issues/210), applied by [chore: move Kamino's secrets to repository level when a second repository joins the organisation](https://git.rkdr.net/Mortis/Kamino/issues/239)). The remaining risk goes into ADR 0001. - Left over, with no issue: whether `image.yml` keeps the job-token probe. This issue calls the probe and `permissions: packages: write` dead weight (not reproduced); [ci: lint workflows with zizmor](https://git.rkdr.net/Mortis/Kamino/issues/145) moves the permission to the job instead. - The first option here (a separate repository for secret-bearing workflows) was not discussed in any map decision. - Both points, and what this issue's text shows on a tracker that is readable without an account, are in [Does the stand-alone rule cover issue text and job logs](https://git.rkdr.net/Mortis/Kamino/issues/253). Recommended: the maintainer closes this issue once that ticket is answered.
Author
Owner

Decided in Does the stand-alone rule cover issue text and job logs: option 1 is rejected for now, option 2 was decided in pieces, and the job-token probe removal moved to #145. This issue is closed and its text redacted by chore: redact host, network and private-repository detail from the tracker.

Decided in [Does the stand-alone rule cover issue text and job logs](https://git.rkdr.net/Mortis/Kamino/issues/253): option 1 is rejected for now, option 2 was decided in pieces, and the job-token probe removal moved to #145. This issue is closed and its text redacted by [chore: redact host, network and private-repository detail from the tracker](https://git.rkdr.net/Mortis/Kamino/issues/265).
Author
Owner

Closed: the choice this issue asked for is made. Option 1 (secret-bearing workflows in a repository only the maintainer can write to) is rejected for now in #253. Option 2 was decided in pieces in #179, #192, #210 and #239. Removing the job-token probe moved to #145.

Closed: the choice this issue asked for is made. Option 1 (secret-bearing workflows in a repository only the maintainer can write to) is rejected for now in #253. Option 2 was decided in pieces in #179, #192, #210 and #239. Removing the job-token probe moved to #145.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#13