Owner-name matching is case-sensitive, so a case-only rename demotes the platform org and blocks all writes #28

Stängd
öppnade 2026-08-04 12:04:10 +00:00 av supernaut · 1 kommentar
Ägare

What happened

On 2026-08-04 the Forgejo organisation was renamed bitborg → Bitborg (a case-only change, made
in the web UI). Within one 5-minute tick the reconciler demoted it to org-default and disabled
Actions:

[reconciler] org Bitborg: quota=org-default actions=false
DELETE /api/v1/admin/quota/groups/org-unlimited/users/Bitborg -> 404 Not Found
PUT    /api/v1/admin/quota/groups/org-default/users/Bitborg   -> 409 Conflict

Effect, for ~90 minutes until the org was renamed back:

  • every push returned Quota exceeded (the org-default 5 GiB cap against ~19 GiB of packages);
  • Forgejo Actions was disabled for the organisation, so CI would not run;
  • package and LFS uploads were blocked by the same cap;
  • it did not self-heal — the reconciler re-asserted the demotion every tick, so any manual quota
    fix would have been undone within 5 minutes.

Root cause

reconciler_org_exempt (infra roles/reconciler/defaults/main.yml) lists the org as bitborg, and
the reconciler compares the org name from the Forgejo API against that list case-sensitively. The
API returned Bitborg, no match, so the org was treated as a tenant org and assigned the default cap.

Because the reconciler is authoritative — it adds the computed group and removes the account from
every other candidate, org-unlimited included — a name that fails to match does not merely fail to
exempt. It actively demotes.

Why this is a real defect and not just a config typo

Forgejo treats owner names as case-insensitive for routing and lookup: /api/v1/orgs/bitborg
resolved fine while the stored login was Bitborg, and the demotion API calls using Bitborg
resolved too. The reconciler comparing them case-sensitively is a mismatch with the platform's own
semantics, and the blast radius of that mismatch is "all writes and all CI for the instance, until a
human notices".

The same reasoning applies to reconciler_user_exempt: a service account or operator whose login
casing differs from the declaration would be demoted to the fail-closed zero-quota participant
group.

Proposed fix

Normalise both sides of the comparison (e.g. casefold/lowercase) wherever an owner name from the API
is matched against a configured exempt list — orgs and users alike. Forgejo's own lower_name column
is the precedent.

Worth considering alongside it: the demotion path is silent. org <name>: quota=org-default is an
INFO-level line indistinguishable from the normal tenant case, so nothing alerts when the platform's
own org gets capped. An alert on "a first-party owner is not in its expected quota group" would have
caught this in minutes rather than at the next push.

Workaround if it recurs before the fix lands

Rename the owner back to the declared casing, then re-apply the group in the same window (runbook §2's
rule — never leave a renamed object without its group):

curl -sS -X POST -H "$H" -H 'Content-Type: application/json' \
  -d '{"groups":["org-unlimited"]}' "$API/admin/users/<org>/quota/groups"
curl -sS -H "$H" "$API/orgs/<org>/quota"   # groups[].rules[].limit must be -1

Note the /orgs/<org>/quota endpoint hides the groups block from unauthenticated callers, so verify
with a token or the check looks like it failed.

## What happened On 2026-08-04 the Forgejo organisation was renamed `bitborg` → `Bitborg` (a **case-only** change, made in the web UI). Within one 5-minute tick the reconciler demoted it to `org-default` and disabled Actions: ``` [reconciler] org Bitborg: quota=org-default actions=false DELETE /api/v1/admin/quota/groups/org-unlimited/users/Bitborg -> 404 Not Found PUT /api/v1/admin/quota/groups/org-default/users/Bitborg -> 409 Conflict ``` Effect, for ~90 minutes until the org was renamed back: - every push returned `Quota exceeded` (the `org-default` 5 GiB cap against ~19 GiB of packages); - Forgejo Actions was disabled for the organisation, so CI would not run; - package and LFS uploads were blocked by the same cap; - **it did not self-heal** — the reconciler re-asserted the demotion every tick, so any manual quota fix would have been undone within 5 minutes. ## Root cause `reconciler_org_exempt` (infra `roles/reconciler/defaults/main.yml`) lists the org as `bitborg`, and the reconciler compares the org name from the Forgejo API against that list **case-sensitively**. The API returned `Bitborg`, no match, so the org was treated as a tenant org and assigned the default cap. Because the reconciler is authoritative — it adds the computed group and *removes* the account from every other candidate, `org-unlimited` included — a name that fails to match does not merely fail to exempt. It actively demotes. ## Why this is a real defect and not just a config typo Forgejo treats owner names as **case-insensitive** for routing and lookup: `/api/v1/orgs/bitborg` resolved fine while the stored login was `Bitborg`, and the demotion API calls using `Bitborg` resolved too. The reconciler comparing them case-sensitively is a mismatch with the platform's own semantics, and the blast radius of that mismatch is "all writes and all CI for the instance, until a human notices". The same reasoning applies to `reconciler_user_exempt`: a service account or operator whose login casing differs from the declaration would be demoted to the fail-closed zero-quota `participant` group. ## Proposed fix Normalise both sides of the comparison (e.g. casefold/lowercase) wherever an owner name from the API is matched against a configured exempt list — orgs and users alike. Forgejo's own `lower_name` column is the precedent. Worth considering alongside it: the demotion path is silent. `org <name>: quota=org-default` is an INFO-level line indistinguishable from the normal tenant case, so nothing alerts when the platform's own org gets capped. An alert on "a first-party owner is not in its expected quota group" would have caught this in minutes rather than at the next push. ## Workaround if it recurs before the fix lands Rename the owner back to the declared casing, then re-apply the group in the same window (runbook §2's rule — never leave a renamed object without its group): ```bash curl -sS -X POST -H "$H" -H 'Content-Type: application/json' \ -d '{"groups":["org-unlimited"]}' "$API/admin/users/<org>/quota/groups" curl -sS -H "$H" "$API/orgs/<org>/quota" # groups[].rules[].limit must be -1 ``` Note the `/orgs/<org>/quota` endpoint hides the `groups` block from unauthenticated callers, so verify with a token or the check looks like it failed.
supernaut refererade till detta ärende från en incheckning 2026-09-29 13:54:28 +00:00
Upphovsperson
Ägare

Deployed to production on 2026-09-29.

The fix (#42) merged on 2026-08-16, but it never shipped: production stayed on v1.4.0 until today. It is now released as v1.4.1 (#63). The infra pin moved in bitborg-infra#503 and was applied.

Verified from the services-host journal in Loki: the 14:21 UTC pass ran git.bitborg.se/bitborg/bitborg-auth-reconciler:v1.4.1, logged reconcile complete (APPLY=true), and bitborg_reconciler_last_run_status is 0. A follow-up --check on the reconciler role shows changed=0.

Deployed to production on 2026-09-29. The fix (#42) merged on 2026-08-16, but it never shipped: production stayed on `v1.4.0` until today. It is now released as `v1.4.1` (#63). The infra pin moved in bitborg-infra#503 and was applied. Verified from the services-host journal in Loki: the 14:21 UTC pass ran `git.bitborg.se/bitborg/bitborg-auth-reconciler:v1.4.1`, logged `reconcile complete (APPLY=true)`, and `bitborg_reconciler_last_run_status` is 0. A follow-up `--check` on the reconciler role shows `changed=0`.
supernaut refererade till detta ärende från en incheckning 2026-10-02 17:57:03 +00:00
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-auth-reconciler#28
Ingen beskrivning angiven.