Co-authored-by: Timothy <timothy@noreply.gitea.tblindustries.be>
14 KiB
key, title, status, since, supersedes, superseded-by, rule, signals, mechanics
| key | title | status | since | supersedes | superseded-by | rule | signals | mechanics |
|---|---|---|---|---|---|---|---|---|
| ci.actions-credential-scoping | 2026-08-05 — CI's registry credential is a scoped PAT, not the admin password, because Gitea cannot separate status-write from repo-write (#697) | active | 2026-08-05 | none | none | Any credential reachable from an Actions job is scoped to what that job needs. The container-registry secret `REGISTRY_PASSWORD` is a personal access token scoped `write:package` + `read:repository` — never an account PASSWORD. This matters because Gitea has NO `status` token scope: `POST /repos/{o}/{r}/statuses/{sha}` is gated by `reqRepoWriter(unit.TypeCode)`, so ANY credential that can write the repository can forge `review-verdict/h10`, the required context that is supposed to make merge-consent derived rather than assertable. Package-write IS a separate scope, so the registry credential can be made status-incapable at no cost: `scripts/ci-detect-already-validated.sh` only GETs. Do NOT add a `permissions:` key to constrain the injected `GITEA_TOKEN` on the assumption that it binds — below Gitea 1.26.0 it is silently a NO-OP, which is worse than absent because it reads in review as a constraint. That version precondition NO LONGER HOLDS: this instance was upgraded 1.25.4 -> 1.27.1 on 2026-08-05. What has NOT changed is that the consequence is unverified — whether `permissions:` is honored here is still UNPROBED, and there is still no API surface for it (`/api/v1/settings/actions` 404s at 1.27.1). The instance default HAS since been probed and is NOT unknown: it was set to Restricted, verified, and reverted to `permissive` on 2026-08-05 (#748), which is where it stands. Probe before relying on it; do not read the upgrade alone as the constraint now working. Scoping is necessary and not sufficient: it bounds what a job may DO, never whether attacker YAML runs at all, so a self-referencing trigger needs its own filter (`ci-image.yml`, tracked in #744 — deliberately NOT bundled here, because editing that file re-points `ci-image-pin` at the editing commit and reddens a blocking job). A second, separate consequence of the same boundary: `actions/checkout` persists a write-capable credential into `.git/config` unless `persist-credentials: false` is set, and 15 of this repo's 16 checkouts now set it (#746), `ci-image.yml`'s being excluded for the reason in that section. Ordering is part of the rule: unmask the dependent fetches FIRST, because until then a credential regression presents as an empty changed-file set and a silently skipped check rather than a red job. This record closes ONE route. It does not close the class, and the later sections say exactly what survives — read them before citing this record as a mitigation. | admin password in CI secrets, registry credential scope, ETV_STATUS_AUTH can write statuses, forge review-verdict/h10, head-resolved workflow holds credentials, persist-credentials on actions/checkout, credential left in .git/config, masked git fetch yields empty changed set, Gitea token scopes, no status scope, write:package vs write:repository, permissions key no-op, GITEA_TOKEN default read/write, Restricted default token permissions, orphan secret, deploy key in secret store, toolchain image overwrite, prod floating tag write · paths: `.gitea/workflows/docker-build.yml`, `.gitea/workflows/pr-checks.yml`, `.gitea/workflows/dependency-scan.yml`, `.gitea/workflows/ci-image.yml`, `.gitea/workflows/renovate.yml`, `scripts/ci-detect-already-validated.sh` · issues: #697, #672, #698, #742, #743, #746, #748, #835, #420, server-management#714 | PAT `ci-registry-scoped-697`, scopes `write:package,read:repository`, stored as repo Actions secret `REGISTRY_PASSWORD`; `REGISTRY_USER` remains `timothy`. Verified 2026-08-05 on Gitea 1.25.4: registry push of a probe tag SUCCEEDED; `GET /commits/{sha}/status` 200; `POST /statuses/{sha}` REFUSED HTTP 403 `token does not have at least one of required scope(s), required=[write:repository], token scope=write:package,read:repository`. Probe artifacts deleted, confirmed 404. NOT measured with this token: the `container:` pull, the buildcache write and the base-image pull. Those rest on Gitea's scope model (write implies read per category, read at tag `v1.25.4`) — INFERRED. Note WHICH run proves which: only the `container:` pull is exercised by a PR. `cache-to`/`cache-from` and the base-image pull are confined to the `build` job, which carries `if: github.event_name != 'pull_request'`, so they are first exercised on the post-merge push to `main` — AFTER the merge gate has passed. A wrong inference there reddens main, not the PR. |
What was wrong. REGISTRY_USER/REGISTRY_PASSWORD were the admin account's basic auth, and
docker-build.yml triggers on pull_request — head-resolved — so a PR's own code got instance-admin
credentials. Basic auth carries no scope: the secret pushing an image administers every repo on the
instance.
Why the credential and not only the triggers. Patching triggers enumerates instances of "a
ref-resolved workflow obtains status-capable credentials", and adding a new workflow file is itself a
route, so that enumeration never completes. But it is not either/or: ci-image.yml's unfiltered
push: is path-scoped to itself, so any branch push runs attacker YAML on a docker-capable runner
with no PR. Scoping bounds what a job may DO; only a filter bounds whether it RUNS. That filter is
#744, not this record: editing ci-image.yml re-points ci-image-pin's expected at the editing
commit and staleness-fails a blocking job. That is a toll, not a wall — the documented two-step
(publish :<short sha>, then bump all five pins) clears it — but a rebase rewrites the sha and charges
it again, so it lands alone (land-toolchain-image-change-separately).
What the scoped token still reaches — not "just a registry credential". write:package over owner
timothy writes ersatztv:prod (the floating tag prod's jazz-media stack follows) and
ersatztv-ci:<sha> (the toolchain image executing five container: jobs). A sha-named tag is not an
immutable artifact (no container tag immutability in Gitea 1.25 — INFERRED), so overwriting the pinned
tag is code execution inside CI, chaining back into the routes below. This is the deployment supply
chain for prod and CI itself.
Admin ownership is a real residual. The PAT is minted under timothy, a site admin. The 403 proves
the scope gate binds the status endpoint ahead of any admin bypass; it does NOT establish that for
package endpoints, where Gitea resolves permission by owner and an admin passes object-level checks,
so the token's package reach is plausibly wider than this repo. A non-admin bot account would close
this, but is not free: packages live in a user namespace only its owner and admins can write. Both
halves INFERRED, neither probed.
Provenance, corrected. review-verdict.yml leaves an existing h10 alone only when it is
positively identifiable as human — non-null .creator.login plus a Review-verdict: description
(release.verdict-status-check). A user credential posts with a real creator and is INHERITED; an
Actions job posts creator: null and is re-derived. That asymmetry is not protection. Re-derivation
fires only on opened|reopened|synchronize|ready_for_review|edited, and posting a status is none of
them, so a POST timed after the last event stands until the attacker merges. The gain here is that PR
code can no longer escalate to instance admin — NOT that the durable forgery route is closed.
The boundary is everything reachable from a job, not the secret store. The store is a useful lower
bound — auditing it rather than the workflow set is what found RENOVATE_TOKEN and
SERVERMGMT_DEPLOY_KEY below, since any PR-added workflow can reference any secret. But
GITEA_TOKEN is injected and never in the store; nor is the credential
actions/checkout persists into .git/config (dropped on 15 of the repo's 16 checkouts in #746;
ci-image.yml is excluded and is head-resolved in the sense that matters — see below); and jobs
reach the runner's docker daemon.
The persisted checkout credential (#746). actions/checkout writes an Authorization header
into .git/config unless persist-credentials: false is set, so a job hands that credential to
every script it runs, not only to the checkout — and it is write-capable while this instance's
Actions default token permission is permissive — where it stands after a Restricted trial was
reverted on 2026-08-05 (#748). 15 of the repo's 16 checkouts
now set it: docker-build.yml (8), pr-checks.yml (5), dependency-scan.yml (1) and
review-verdict.yml (1, pre-existing). No job that checks out pushes with git, so none of them
loses a capability; renovate.yml does push, but has no checkout step and uses RENOVATE_TOKEN.
Unmask the dependent fetches BEFORE dropping a persisted credential — the rule, not a note about
one change. Five steps fed git fetch ... origin "$base_ref" || true into changed-file skip logic,
where a credential regression reddens nothing: on the three that also masked git diff it yields an
empty changed set the skip logic reads as "nothing changed", and on the other two it hands a
possibly-absent origin/<base> to a validator. Anonymous fetch does cover this repo (public; git-upload-pack answers
unauthenticated, measured 2026-08-26), which is a reason to make the failure loud rather than a
reason to trust it silently. The same step is where --depth came off those fetches: their jobs
check out fetch-depth: 0, and git fetch --depth=N grafts a complete clone shallow, so a
three-dot diff against a branch point further back than N fails no merge base — invisible under
|| true, and without it a red api-docs/Formatting (decisions lifecycle would stay green with
its diff-dependent checks skipped, because its validator fails open on an unresolvable base).
ci-image.yml's single checkout is the one exception, and NOT because it is safe: its unfiltered
push trigger makes it head-resolved in the sense that matters. It is excluded because editing that
file re-points ci-image-pin's expected at the editing commit and reddens a blocking job, and
because the same trigger would publish a toolchain image from the editing branch. It rides with
#744, which exists to change that file alone. #835 tracks the guard for this convention: it can only
be written without an exemption list once #744 has landed.
Measured vs inferred. Measured here: the v1.25.4 scope enum (access_token_scope.go) has no
status entry; the reqRepoWriter gate (routers/api/v1/api.go); the probes in mechanics. Read from
docs, NOT verified (2026-08-05): permissions: landed in 1.26.0 (Gitea PR #36173); no app.ini lever
at any version; Gitea rejects GitHub's statuses/checks scopes.
Version caveat — this record's measurements are pinned to 1.25.4, the instance is now 1.27.1.
The instance was upgraded mid-session on 2026-08-05 (#743). Everything above measured on 1.25.4 is
therefore a dated claim, not a current one: the scope enum, the reqRepoWriter gate and the 403
probe were all taken pre-upgrade and have NOT been re-run. They are recorded honestly as of their
date and are the best evidence available, but do not cite them as current behaviour without
re-probing. Re-verification of the 1.25.4-pinned claims across the CI docs is tracked separately.
Surviving routes — this record is not a mitigation for any of them. RENOVATE_TOKEN is a
write:repository bot PAT in the same store, posting with a real creator, and cannot be scoped down
because Renovate needs repo write (#742). The injected GITEA_TOKEN is write-capable in every job;
only Gitea >=1.26 with the Actions default set to Restricted binds it (server-management#714).
Both halves of that condition have now been checked and it does not hold, because of the second one:
the version half IS satisfied (1.27.1), while the default was set to Restricted, verified, and
reverted to permissive on 2026-08-05 because this repo is not ready for it (#748). So the route is
open, and open for a known reason rather than an unprobed one — waiting on a further Gitea upgrade
would be waiting on the wrong thing. A
collaborator's own token always can. docker-build.yml publishes :prod from a v* tag push and a tag
may point at ANY commit — a prod image with no PR, review or status (tag protections are empty).
And none of it was necessary: direct pushes to main were server-side permitted, so the gate was
bypassable with no forgery at all (#743). That route is now closed — main carries
enable_push: false (release.main-direct-push-disabled), which removes main as a destination for
every write-only credential in this list, including the injected GITEA_TOKEN and RENOVATE_TOKEN.
It does not remove them as forgery routes on the PR path, and it does not bind an admin credential,
which can PATCH the protection off first. Correction to this record's earlier wording: a push
whitelist would NOT have closed more of the class than the upgrade — measured 2026-08-05, a
whitelist naming timothy still admitted the push, and every credential here acts as timothy.
Treat this list as "at least these", never exhaustive. SERVERMGMT_DEPLOY_KEY remains in the
store though its bump-prod-compose job went in 1b5efd7b9, and its key on timothy/server-management
is read_only: false — write access to the repo holding prod's GitOps stack definitions. Left in place
by explicit decision 2026-08-05; recorded so it is accepted, not forgotten. Severity throughout: push
access required, so a compromised contributor or subverted automated session, never an anonymous one.