docs(security): ratify AR-1 MFA for platform roles
AR-1 option B (BDR-083): aal2 for every platform role change. Contract 5.7 rule, path inventory, bootstrap, factors, recovery, sessions; F17-F19; M4 scope, tests, DEV preconditions; fresh security review integrated (19.4).
This commit is contained in:
1 parent
41d3b09120
commit
9c13bae4bc
5 files changed
+447
-57
No files matched your search
@@ -603,3 +603,13 @@ Supersedes for official sheets the 2026-10-25 rule « no graphic editor until St
|
||||
Consolidation also fixed: rights table moved to M4 (M4 used table created in M5); core step V1-2.2 now before worker step V1-2.3; progressive review via per-group acknowledgments with digests.
|
||||
Alt: options not chosen listed in contract §17 and the 2026-10-28 review; O15 B and O4 C rejected outright.
|
||||
Status: ratified; contract under owner final review; V1-2.1 not authorised.
|
||||
|
||||
## BDR-083 | 2026-10-28 | AR-1 ratified option B: aal2 for every platform role change
|
||||
|
||||
Decision (owner brief « V1-2.0 : résolution définitive d'AR-1 »): grant, revoke, replace, promote, demote of any platform role (owner, admin, moderator, support) need valid aal2 session, checked server-side in RPC at call time. No permanent exception (owner, first admin, old accounts, admin UI, direct RPC). aal2 necessary never sufficient: can_manage_platform_role, self-target refusal, last-owner guard stay. Ordinary users no MFA. Completes O4, no change to D1-D9, O1-O23.
|
||||
Why: aal1 owner session could grant owner to attacker account → enrol own TOTP → aal2 → self-grant all catalogue capabilities. Read from `20261008100200` RPCs.
|
||||
Shape (contract §5.7): aal2 check 2nd after auth, before role checks (no role oracle); private assign/withdraw re-check for non-null actor; service_role revoked on profile_roles/profiles + RPC EXECUTE (F17); owner-count race locked (F18); first owner: enrol 2 factors first, role assigned last by operator; DEV owner: enrol before M4 applied; recovery operator-only, ban account during enrol window; GoTrue v2.197.0 enrol/unenroll need aal2 once verified factor (source read, sandbox proves).
|
||||
Alt: A (owner+admin only) rejected: leaves moderator/support weak path; C (accept residual) rejected.
|
||||
Review (fresh challenger FATAL(4), all integrated, no ratified decision changed): grant needs target with verified factor; private fns: non-null actor = auth.uid() + aal2, null actor only without JWT; advisory lock both RPCs; DEV precondition before M4 = ENVIRONMENTS §3.6 hardening (public default JWT secret + demo service key + 54321 LAN → aal2 forgeable) + seed owner password changed + role holders listed; recovery reordered (ban, password set with owner, unban, enrol).
|
||||
Reserves: staff read policies (is_platform_admin) stay aal1, owner decision; stolen aal2 session residual; refused attempts not in audit table.
|
||||
Status: ratified; contract only, no code/migration/DEV change; V1-2.1 not authorised.
|
||||
@@ -467,3 +467,8 @@ R5.4: `draft/{labels,changelog,review_report,drawing,overlay,app_review,svg_comp
|
||||
- Contract rewritten: rights M4, catalogue access fail-closed, MFA + operator recovery, group acknowledgments, worker verdict states, species inactive, equine working copy, SQL mirror removal, steps §16 with 9 headings.
|
||||
- 3 fresh challengers: business CONCERNS, security FATAL (AR-1: aal1 owner grants owner role → bypasses catalogue MFA; O4-D unratified → owner arbitration), simplicity CONCERNS. All other findings integrated (omitted status = inherited, F12 unconditional, F15/F16, reader row predicate, uploads to M5, PreviewSheet editor handle, removal groups).
|
||||
- Docs only, committed + pushed on feature/v1-2-anatomical-sheets. STOP: verdict BLOCKED on AR-1.
|
||||
|
||||
## 2026-10-28 (V1-2.0 AR-1 B ratified, contract updated)
|
||||
- Owner ratified AR-1 B (BDR-083). Contract §5.7 written: rule, chain, path inventory (2 RPCs, 2 private fns, service_role table grants F17, owner-count race F18), bootstrap, factor/password/recovery, session rules, deploy order (enrol before M4 on DEV), tests §15.
|
||||
- GoTrue v2.197.0 source read: enrol needs aal2 once verified factor, unenroll verified needs aal2. auth.sessions check kept as to-verify.
|
||||
- Docs only. Independent security review, then commit + push feature branch. STOP at checkpoint.
|
||||
@@ -535,7 +535,8 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet
|
||||
- [ ] V1-2.0 contract and decisions (docs only): read-only audit delivered; contract drafted; 3 fresh plan challengers (correctness, robustness, simplicity); doc fixes (V1-1 status in TODO + V1-1 contract header, CLAUDE.md M1-M3 line); challengers FATAL(2 blockers)/FATAL(1)/CONCERNS integrated (contract §19); STOP at checkpoint: owner ratification of §5-§16 and options O1-O20
|
||||
- [x] owner review of O1-O20 delivered (2026-10-28, read-only); O21-O23 proposed (catalogue access, SQL mirror, failed verification)
|
||||
- [x] owner ratified O1-O23 (brief « V1-2.0 : ratification des arbitrages O1 à O23 et consolidation du contrat », 2026-10-28, BDR-082)
|
||||
- [ ] consolidation (docs only): contract rewritten (decisions §17, contradictions C1-C14 §19.2, steps §16 with 9 headings each); IMPLEMENTATION_PLAN §0 + Steps 13/17 notes, ANATOMICAL_SHEET_MODEL stale Zod/TS mentions + V1-2 pointer, OPEN_QUESTIONS conflicts 1-2, V1-1 §5.4 pointer (N1 amended), rule sheet-model, CLAUDE.md pointer; 3 fresh challengers (business CONCERNS 3 major, security FATAL 1 arbitration + 6 major, simplicity CONCERNS 5 major) integrated (contract §19.3); commit + push branch; STOP at checkpoint: owner final review + AR-1 (MFA on platform role grants, contract §17.2), no V1-2.1
|
||||
- [ ] consolidation (docs only): contract rewritten (decisions §17, contradictions C1-C14 §19.2, steps §16 with 9 headings each); IMPLEMENTATION_PLAN §0 + Steps 13/17 notes, ANATOMICAL_SHEET_MODEL stale Zod/TS mentions + V1-2 pointer, OPEN_QUESTIONS conflicts 1-2, V1-1 §5.4 pointer (N1 amended), rule sheet-model, CLAUDE.md pointer; 3 fresh challengers (business CONCERNS 3 major, security FATAL 1 arbitration + 6 major, simplicity CONCERNS 5 major) integrated (contract §19.3); commit + push branch; STOP at checkpoint: owner final review, no V1-2.1
|
||||
- [x] AR-1 ratified option B by the owner 2026-10-28 (BDR-083): `aal2` on every platform role change; contract §5.7 (rule, inventory, bootstrap, factors, recovery, sessions), F17-F19, M4 scope, tests §15, DEV order §16.11 (enrol before M4); docs only; independent security review then commit + push; no code, migration or DEV change
|
||||
- [ ] V1-2.1 server access and workflow (M4, M5) · V1-2.2 core verdict, preview, change list, edit primitives, SVG cleaning · V1-2.3 drawings and worker verification (M6) · V1-2.4 wireframes (editor, review, admin entry) · V1-2.5 catalogue, admin space, rights, species, MFA · V1-2.6 editor level 1 · V1-2.7 preview, review, publication UI · V1-2.8 equine working copy and review preparation · V1-2.9 FR/EN acceptance and closure (owner checkpoints V1-2.3, V1-2.4, V1-2.6, V1-2.7, V1-2.8, V1-2.9 + each DEV operation of contract §16.11)
|
||||
|
||||
## Release readiness track (owner 2026-10-25, distinct from the functional roadmap; nothing here authorises a release or exposure)
|
||||
|
||||
@@ -90,6 +90,9 @@ enforced by an RLS helper `has_mfa()` on admin tables. Today:
|
||||
- app: no enrolment UI (QR + code), no `aal2` step-up on sign-in;
|
||||
- there is no admin table or screen yet to protect.
|
||||
|
||||
V1-2 decision (BDR-083): `aal2` is required for every platform role change,
|
||||
see `V1-2_ANATOMICAL_SHEETS.md` §5.7 (rule, bootstrap, recovery).
|
||||
|
||||
The Security section shows a note instead. To close the gap (a later step):
|
||||
migration adding `private.has_mfa()` and folding it into `is_platform_*` (or
|
||||
into the policies of the first admin table) with pgTAP allowed/denied cases;
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
# V1-2 Anatomical sheets: contract
|
||||
|
||||
Status: decisions RATIFIED, contract consolidated for the owner's final
|
||||
review (V1-2.0, 2026-10-28), with ONE OPEN ARBITRATION REQUEST (AR-1, §17.2).
|
||||
review (V1-2.0, 2026-10-28). The arbitration AR-1 is closed: the owner
|
||||
ratified option B (`aal2` for every platform role change, §5.7, §17.2,
|
||||
BDR-083).
|
||||
The owner approved the orientations D1 to D8 and added the mandatory
|
||||
requirement D9 (BDR-081, 2026-10-27), then ratified the decisions O1 to O23 in
|
||||
the brief « V1-2.0 : ratification des arbitrages O1 à O23 et consolidation du
|
||||
contrat » (2026-10-28, BDR-082). This revision writes those decisions into the
|
||||
rules, resolves the contradictions C1 to C14 found at the review of the first
|
||||
revision (§19.2), restates the step plan (§16) and integrates a second round
|
||||
of fresh challenges (§19.3), one finding of which needs the owner (AR-1). It
|
||||
of fresh challenges (§19.3), one finding of which needed the owner (AR-1,
|
||||
decided) and a third review of the AR-1 B text (§19.4). It
|
||||
authorises no implementation: V1-2.1 starts only on the owner's explicit go.
|
||||
V1-2.0 changes no code, migration, policy, RPC, anatomical data or DEV state.
|
||||
|
||||
@@ -31,7 +34,7 @@ Parts: 1 facts, 2 scope, 3 nomenclature, 4 decisions D1 to D9, 5 access, roles
|
||||
and permissions, 6 lifecycle, review, verification and publication, 7 species
|
||||
and new sheets, 8 editor, 9 drawings, 10 loading, 11 screens and journeys,
|
||||
12 SQL defects, SQL authority and migrations, 13 security, 14 equine sheet,
|
||||
15 tests, 16 implementation steps, 17 ratified decisions and open arbitration,
|
||||
15 tests, 16 implementation steps, 17 ratified decisions and arbitration,
|
||||
18 documents touched by V1-2.0, 19 challenge record.
|
||||
|
||||
---
|
||||
@@ -192,7 +195,7 @@ Each layer is checked on the server; none implies the next.
|
||||
| Historical reads | the same predicate (O8) | published and deprecated versions by id, archived sheets included |
|
||||
| Draft reads | a capability and `aal2` | drafts, rounds, verdicts, comments, history, drawings of drafts |
|
||||
| Capabilities | `anatomical_catalog_grants` (§5.2) and `aal2` | edit, review, publish, per the matrix of §5.4 |
|
||||
| Platform role | `profile_roles` | a precondition of `sheet_editor` and `sheet_publisher`; no catalogue right by itself |
|
||||
| Platform role | `profile_roles`, changed only with `aal2` (§5.7) | a precondition of `sheet_editor` and `sheet_publisher`; no catalogue right by itself |
|
||||
| Professional status | plan Step 9, not built | none; never inferred from a right or a role |
|
||||
| Workspace membership | V1-1 tables | none: no catalogue rule reads workspace tables and no V1-1 rule reads catalogue tables |
|
||||
|
||||
@@ -374,14 +377,17 @@ A1 to A6):
|
||||
- Enrolment (V1-2.5, Mon compte, Sécurité): add a TOTP factor (QR code, the
|
||||
secret shown once and never stored or logged by the application), verify
|
||||
it with a code (a factor counts only once verified), name, list and remove
|
||||
factors. Supabase requires an `aal2` session to remove a verified factor.
|
||||
factors. GoTrue v2.197.0 requires `aal2` to enrol a factor once one is
|
||||
verified and to remove a verified factor (§5.7.3, from its source).
|
||||
V1-2.5 proves that an `aal1` session of an account with a verified factor
|
||||
cannot enrol another factor; if Supabase allowed it, the step stops for an
|
||||
owner decision, since MFA would then be bypassable with the password alone.
|
||||
can neither enrol another factor nor remove one; if the sandbox shows
|
||||
otherwise, the step stops for an owner decision, since MFA would then be
|
||||
bypassable with the password alone.
|
||||
- Step-up: entering `/app/admin` with an `aal1` session opens the challenge;
|
||||
success upgrades the session; no admin data is requested before.
|
||||
- Sessions: `aal2` belongs to the session. A token refresh keeps it, sign-out
|
||||
ends it, a new sign-in starts at `aal1` (Supabase behaviour, proven by a
|
||||
ends the session (an access token already issued stays valid until
|
||||
`jwt_expiry`), a new sign-in starts at `aal1` (Supabase behaviour, proven by a
|
||||
V1-2.5 browser test). The access token lives `jwt_expiry` (3 600 s in the
|
||||
local configuration; V1-2.1 records the values of the sandbox and DEV). No
|
||||
session time box or inactivity limit is configured, and V1-2 adds no
|
||||
@@ -408,14 +414,297 @@ A1 to A6):
|
||||
The owner's own loss follows the same procedure, run by the owner at the
|
||||
server. The runbook goes to `IDENTITY.md` and is rehearsed on the sandbox in
|
||||
V1-2.9.
|
||||
- Platform roles (O4-D): `grant_platform_role` and `revoke_platform_role`
|
||||
require no `aal2`, and an owner may grant the owner role. The first revision
|
||||
of this contract claimed that the catalogue stays closed without O4-D; the
|
||||
security challenge of §19.3 showed it does not (an `aal1` owner session
|
||||
grants owner to another account, which enrols its own factor and grants
|
||||
itself every capability). O4-D was not ratified, so the contract does not
|
||||
extend `aal2` to those RPCs: the choice is the open arbitration AR-1
|
||||
(§17.2).
|
||||
- Platform roles (AR-1 B, ratified 2026-10-28): `grant_platform_role` and
|
||||
`revoke_platform_role` require `aal2` for every platform role; see §5.7.
|
||||
The earlier option O4-D, left unratified by O4, is superseded by that
|
||||
arbitration.
|
||||
|
||||
### 5.7 Platform role changes and MFA (AR-1 B)
|
||||
|
||||
Ratified by the owner on 2026-10-28 (BDR-083). It completes the security
|
||||
contract of O4; it replaces none of O1 to O23.
|
||||
|
||||
**Rule.** Every grant, revocation, replacement, promotion, demotion or
|
||||
equivalent change of a platform role (`owner`, `admin`, `moderator`,
|
||||
`support`) requires a valid `aal2` session, checked on the server when the
|
||||
operation runs. A hidden button is not a control. There is no exception for
|
||||
the owner, the first administrator, accounts already privileged, older
|
||||
accounts, the administration screens or direct RPC calls; the only path
|
||||
without a session is the audited operator path outside the application
|
||||
(§5.7.5), used for a bootstrap or a recovery. `aal2` is necessary
|
||||
and never sufficient: `can_manage_platform_role`, the self-target refusal and
|
||||
the last-owner guard still apply. Ordinary accounts are not asked for MFA; the
|
||||
requirement covers the operations of this contract (platform roles, catalogue
|
||||
rights, catalogue administration, protected drafts, review, publication).
|
||||
Reading the published catalogue follows O21.
|
||||
|
||||
**The flaw and the chain it closes.** `grant_platform_role` and
|
||||
`revoke_platform_role` check the caller's role, not its assurance level:
|
||||
|
||||
1. an attacker learns the password of an owner;
|
||||
2. they open a session, which is `aal1`;
|
||||
3. they call `grant_platform_role` directly and give `owner` or `admin` to an
|
||||
account they control (or revoke the real owner);
|
||||
4. that account enrols its own TOTP factor (a first factor is enrolled at
|
||||
`aal1`) and reaches `aal2`;
|
||||
5. it grants itself `sheet_editor`, `sheet_reviewer`, `sheet_publisher`
|
||||
(§5.2) and reviews and publishes official sheets.
|
||||
|
||||
With AR-1 B, step 3 is refused with no write, so steps 4 and 5 never start.
|
||||
|
||||
**Why B and not A.** A (owner and admin only) leaves `moderator` and `support`
|
||||
changeable from a password-only session. They give no catalogue right today;
|
||||
`support` opens staff reads (`profiles_select_staff`), and any future
|
||||
role-based rule would inherit a weak path; revoking them is also a nuisance
|
||||
attack. B
|
||||
costs the same one predicate and removes the list of roles from the rule.
|
||||
|
||||
**Inventory of the paths that change platform privileges** (read from the
|
||||
migrations and `seed.sql` on 2026-10-28; V1-2.1 re-runs the census in pgTAP
|
||||
001):
|
||||
|
||||
| Path | Who may call it today | Controls today | Added by M4 | Audit |
|
||||
|---|---|---|---|---|
|
||||
| `public.grant_platform_role(target, role)` | `authenticated` (and `service_role`, which fails at `auth.uid()` null) | authenticated, not self, `can_manage_platform_role` (owner: any role; admin: moderator and support), not already active | `has_mfa()` as the second check; `EXECUTE` revoked from `service_role` | `platform_role.granted` |
|
||||
| `public.revoke_platform_role(target, role, reason)` | same | same, plus the last-owner guard | same, plus the guard made race-free (F18) | `platform_role.revoked` |
|
||||
| `private.assign_platform_role`, `private.withdraw_platform_role` | no API role (`EXECUTE` revoked from public, schema `private` not exposed); RPCs above and privileged SQL sessions | none of their own | a non-null actor must equal `auth.uid()` and pass `has_mfa()`; a null actor is accepted only when the request carries no JWT (`auth.role()` null), so neither an API session nor `service_role` reaches the operator path (§5.7.5) | same events |
|
||||
| `private.can_manage_platform_role` and the `has_platform_role` family | predicates, no write | n/a | unchanged; `is_platform_*` do not read the assurance level (policies that use them for reads are out of AR-1, see reserves) | none |
|
||||
| table `public.profile_roles` | `authenticated`: SELECT only, no write policy; `service_role`: default table privileges never revoked (F17) | RLS, privileges | `REVOKE ALL` from `service_role` on `profile_roles` and `profiles` (F17) | none |
|
||||
| `profiles.active` (deactivation changes who counts as a role holder) | no user path: not in the column grant of UPDATE | column grants | F17 covers `service_role` | none |
|
||||
| triggers and `handle_new_auth_user` | none writes `profile_roles` | n/a | census asserts it stays so | none |
|
||||
| `seed.sql` bootstrap (`assign_platform_role(null, ...)`) | local stacks, privileged SQL | none | unchanged, local only (§5.7.5) | `platform_role.granted`, null actor |
|
||||
| deletion of an auth user (cascade `on delete cascade` to `profile_roles`) | GoTrue admin API with the service key | none | operator procedure only (§5.7.5) | auth log |
|
||||
| `grant_catalog_right`, `revoke_catalog_right` (M4, §5.2) | owner | owner, `aal2` | already `aal2` | per §5.2 |
|
||||
|
||||
No other path reachable from a user session was found: PostgREST exposes the
|
||||
`public` schema only, and every write to `profile_roles` goes through the two
|
||||
RPCs. A claim that this closes service-key abuse would be false: see §5.7.5.
|
||||
|
||||
**Order of checks in both RPCs** (M4), all before any write:
|
||||
|
||||
1. `auth.uid()` is not null;
|
||||
2. `has_mfa()`; otherwise a refusal with the closed kind `mfa_required`;
|
||||
3. the caller is not the target;
|
||||
4. `can_manage_platform_role`;
|
||||
5. the operation is valid: target exists and is active; for a grant, the
|
||||
target holds a verified factor (the eligibility predicate of §5.2), so no
|
||||
role lands on an account whose first factor a password or mailbox holder
|
||||
could still enrol; role not already active, or active for a revocation;
|
||||
last active owner kept;
|
||||
6. the write and its audit row, in the same transaction.
|
||||
|
||||
The assurance check comes before the role checks so that a password-only
|
||||
session gets the same answer whatever role it holds: no oracle on who is
|
||||
owner or admin. A refusal raises, so it leaves no row (neither the role nor an
|
||||
audit row); attempted escalations are therefore visible in the API logs, not
|
||||
in the audit table. With `[analytics] enabled = false` a raised refusal
|
||||
reaches the PostgreSQL log only (residual). Returning the refusal as a
|
||||
closed kind after a committed `log_event` is an option V1-2.1 may propose,
|
||||
not a decision taken here.
|
||||
|
||||
**Race on the last owner (F18).** `withdraw_platform_role` counts owner rows
|
||||
without a lock and without `profiles.active`, so two simultaneous
|
||||
revocations of two owners can both pass and leave none (or only a deactivated
|
||||
one). M4 takes one transaction-scoped advisory lock at the start of both RPCs
|
||||
and of the private functions, before checks 3 to 5, and counts owners with
|
||||
the `has_platform_role` semantics (active profile). Two-session tests: mutual
|
||||
revocation, revoke against grant.
|
||||
|
||||
#### 5.7.1 First enrolment and the bootstrap of the first owner
|
||||
|
||||
GoTrue v2.197.0 (the image pinned by the local stack; source read on
|
||||
2026-10-28, behaviour to be proven on the sandbox by V1-2.5):
|
||||
`EnrollFactor` refuses with `insufficient_aal` when the user already has a
|
||||
verified factor and the session is not `aal2`. With no verified factor, a first
|
||||
factor is enrolled from an `aal1` session. Enrolling, verifying and reaching
|
||||
`aal2` are three steps: a factor counts once verified, and verification
|
||||
upgrades the session and invalidates the user's sessions below `aal2`.
|
||||
|
||||
Ordinary journey: password sign-in (`aal1`) → Mon compte, Sécurité → enrol
|
||||
TOTP → verify with a code → `aal2`. Enrolling a factor grants no role and no
|
||||
capability; MFA is a condition, never a substitute for the checks of §5.2 and
|
||||
§5.7.
|
||||
|
||||
New environment (no owner, no `aal2` session anywhere), in this order, never
|
||||
the reverse:
|
||||
|
||||
1. the operator creates the account through the sign-up path or the admin
|
||||
API, email confirmed, and hands over the initial secret out of band;
|
||||
2. the future owner signs in, enrols two TOTP factors on two devices and
|
||||
verifies both; no role exists yet, so nothing is at stake in the window;
|
||||
3. the operator checks, read-only, that the account has verified factors and
|
||||
that their names and creation times match what the owner did;
|
||||
4. only then the operator assigns the owner role from a privileged SQL
|
||||
session (`assign_platform_role(null, ...)`) and records, in the same
|
||||
session, an audit row with the reason and the operator's name through
|
||||
`private.log_event`;
|
||||
5. the owner signs in again, passes the step-up, and proves an `aal2` call
|
||||
works and an `aal1` call is refused.
|
||||
|
||||
No public RPC creates an owner, none disables MFA, and no permanent bypass
|
||||
exists. The `seed.sql` bootstrap (role assigned before any factor, known
|
||||
password) is a local-fixture exception to this order, acceptable only on a
|
||||
stack no untrusted party can reach (§5.7.2). Assigning the role last is what closes trust on first use for the
|
||||
owner account.
|
||||
|
||||
#### 5.7.2 DEV: preconditions of the future transition
|
||||
|
||||
The DEV owner is the seed account, it has no factor, and nothing changes on
|
||||
DEV during V1-2.0. Two facts of DEV defeat AR-1 B as long as they hold:
|
||||
|
||||
- the stack signs tokens with the Supabase CLI's public default JWT secret,
|
||||
its `service_role` key is the public demo key, and port 54321 is open to
|
||||
the LAN (`ENVIRONMENTS.md` §3.6, risk accepted by the owner on 2026-10-24
|
||||
« before any untrusted device or user »). Anyone on the network can mint an
|
||||
`aal2` token for the owner, or act as `service_role`; `has_mfa()` proves
|
||||
nothing there;
|
||||
- the owner account's password is the seed's, committed in Git.
|
||||
|
||||
So, before the owner applies M4 on DEV or makes the first grants (§16.11):
|
||||
|
||||
0. the §3.6 hardening is done (own JWT secret or signing keys, or 54321
|
||||
narrowed to the test devices; the owner's choice), and the seed owner's
|
||||
password is changed, or a separate owner is bootstrapped per §5.7.1 and
|
||||
the seed owner revoked; every active `profile_roles` row of DEV is listed,
|
||||
and each holder enrols and verifies a factor before M4 or loses the role;
|
||||
1. read-only check of every factor of each role holder, verified or not (an
|
||||
unknown one is deleted, and an unknown verified one means a reset first,
|
||||
§5.7.7);
|
||||
2. the owner enrols two factors and verifies both from the branch's Mon
|
||||
compte; this needs no migration, and until M4 is applied every existing
|
||||
right is unchanged;
|
||||
3. on the sandbox rehearsal of M4 from the DEV state, `aal2` is shown to
|
||||
work and `aal1` to be refused for the same account;
|
||||
4. the recovery of §5.7.7 has been rehearsed on the sandbox;
|
||||
5. a backup exists.
|
||||
|
||||
Any `db:reset`, or `db:start` on a fresh volume, of DEV after M4 reruns the
|
||||
seed and reopens these preconditions.
|
||||
|
||||
A failed transition is never a lockout: an owner without a verified factor
|
||||
still signs in and uses the application at `aal1`, only role and rights
|
||||
management waits, and the first factor can always be enrolled at `aal1`.
|
||||
|
||||
#### 5.7.3 Additional, removed and replaced factors
|
||||
|
||||
Native behaviour of GoTrue v2.197.0 (source read, V1-2.5 proves it):
|
||||
|
||||
- a second factor: `EnrollFactor` needs `aal2` once a verified factor exists
|
||||
(403 `insufficient_aal`). A stolen password therefore cannot add a factor;
|
||||
- removing a verified factor: `UnenrollFactor` needs `aal2` (422
|
||||
`insufficient_aal`); an unverified factor can be removed from `aal1`. An
|
||||
unverified factor gives no `aal2` until verified, so a dormant one left by
|
||||
an earlier password holder is a path: factor checks list unverified
|
||||
factors too, and V1-2.5 tests a dormant factor verified later (GoTrue
|
||||
appears to delete unverified factors of the same type on verification;
|
||||
not assumed). Assumption: TOTP is the only enabled factor type;
|
||||
- removing the last factor: allowed from `aal2`. The account then returns to
|
||||
the first-factor case, where an `aal1` session can enrol; a role holder in
|
||||
that state keeps the role (residual, §13). A stolen `aal2`
|
||||
session can therefore replace factors; this is the stolen-session residual
|
||||
(§5.7.8), not a bypass from the password alone;
|
||||
- GoTrue downgrades the sessions of a removed factor to `aal1`
|
||||
(`DowngradeSessionsToAAL1`); its exact scope and the lifetime of
|
||||
already-issued access tokens are recorded by V1-2.5, not assumed;
|
||||
- freshness: tokens carry `amr` entries (method and time), so a recent-TOTP
|
||||
check on the rare role RPCs is technically possible; adopting it is an
|
||||
owner choice under O4, not part of this contract (§5.7.9).
|
||||
|
||||
If the sandbox shows `aal1` can enrol a second factor or remove a verified
|
||||
one, V1-2.5 stops for an owner decision (as §5.6 already says).
|
||||
|
||||
#### 5.7.4 Password change and reset
|
||||
|
||||
A reset or change of password yields an `aal1` session. For an account with a
|
||||
verified factor it cannot add or remove a factor (§5.7.3) and cannot change a
|
||||
platform role (rule above). For an account without a verified factor, the
|
||||
reset lets whoever holds the mailbox enrol a first factor: this is the
|
||||
accepted first-factor case, harmless while no role or capability is held, and
|
||||
the reason the owner role is assigned after enrolment (§5.7.1) and a
|
||||
capability only to an account with a verified factor (§5.2). Email change and
|
||||
identity linking stay as configured (`enable_manual_linking = false`); V1-2.5
|
||||
adds a test that none of them raises a session to `aal2`.
|
||||
|
||||
#### 5.7.5 Operator path
|
||||
|
||||
The technical paths are the service key (RLS bypass and GoTrue admin) and a
|
||||
privileged SQL session on the database container. They are not exceptions
|
||||
usable from the application: the app never holds the service key; the worker
|
||||
holds it and can call worker RPCs only; the role RPCs refuse `service_role`
|
||||
(no `auth.uid()`, and `EXECUTE` revoked in M4). Each use is an owner-authorised
|
||||
operation (§16.11), written down with its reason, and leaves an audit row
|
||||
(`private.log_event`, null actor, operator in the detail) in the same
|
||||
session.
|
||||
|
||||
#### 5.7.6 Actors
|
||||
|
||||
| Actor | Can change platform roles | Note |
|
||||
|---|---|---|
|
||||
| Ordinary account | no | no MFA requirement for ordinary use |
|
||||
| Owner or admin at `aal1` | no | refused at check 2 whatever the role |
|
||||
| Owner or admin at `aal2` | within `can_manage_platform_role` | admin: moderator and support only |
|
||||
| Moderator or support at `aal2` | no | `aal2` is not sufficient |
|
||||
| Worker | no | worker RPCs only (M6) |
|
||||
| `service_role` key holder | not through the RPCs; yes through GoTrue admin and SQL | outside MFA, §5.7.5 and §13 |
|
||||
| Operator SQL session | yes | audited by procedure, not by the database |
|
||||
|
||||
#### 5.7.7 Recovery
|
||||
|
||||
Complements the procedure of §5.6, which stands (operator only, out-of-band
|
||||
identity, reason recorded, no RPC, no screen).
|
||||
|
||||
- Lost phone, account with other factors or another admin: the person uses
|
||||
the second factor. A person whose only factor is lost follows §5.6 steps 1
|
||||
to 4.
|
||||
- Loss of every factor of the last owner: no application path exists, by
|
||||
design. On a single-owner platform the operator is the owner acting at the
|
||||
server, and the real control is server access, not a second person. Order:
|
||||
1. the operator signs out every session, deletes every factor (verified or
|
||||
not), bans the account and writes the audit row `auth.mfa_factor_reset`;
|
||||
2. with the owner present, the operator sets a new password with the owner
|
||||
and lifts the ban;
|
||||
3. the owner signs in at once, enrols and verifies two factors;
|
||||
4. the operator lists every factor of the account; any it does not
|
||||
recognise sends the procedure back to step 1.
|
||||
The owner role and the owner's capabilities stay in place: inert at
|
||||
`aal1`, since `caller_has` and the role RPCs need `aal2`. Nothing is
|
||||
re-granted. (For another account, §5.6 step 2 applies: the owner revokes
|
||||
its capabilities first.)
|
||||
- Return to a safe state: `aal2` proven and `aal1` refused again on that
|
||||
account; the audit rows exist; no temporary bypass was left.
|
||||
- Rehearsed on the sandbox in V1-2.9; the runbook goes to `IDENTITY.md`.
|
||||
Secrets (QR codes, TOTP seeds) never go in Git, documents, logs or tickets.
|
||||
Prevention: two factors on two independent devices for every owner.
|
||||
|
||||
#### 5.7.8 Sessions, tokens and stale rights
|
||||
|
||||
- Roles and capabilities are read from the tables at every call; the project
|
||||
adds no claim to the JWT (no access-token hook), so a revoked right or role
|
||||
is refused at the next call whatever the token says.
|
||||
- The `aal` claim lives as long as the access token (`jwt_expiry`, 3 600 s
|
||||
locally). For the role and rights RPCs only (rare, administrative), V1-2.1
|
||||
adds a check that the session named by the token's `session_id` still
|
||||
exists in `auth.sessions` at `aal2`. The columns and the claim are verified
|
||||
on the pinned image first; if one is missing, V1-2.1 stops for an owner
|
||||
decision (claim alone with the residual of up to one token lifetime after
|
||||
a downgrade, or another check). Nothing here is assumed present.
|
||||
- A stolen `aal2` session is a distinct risk this design does not remove:
|
||||
it keeps working until it ends. Reducing it (freshness window, session
|
||||
limit) is not part of V1-2.
|
||||
- Concurrent role changes: unique active row per (user, role), lock on the
|
||||
owner count (F18), one transaction per write.
|
||||
|
||||
#### 5.7.9 Reserves recorded, not decided
|
||||
|
||||
- `is_platform_admin` and the staff read policies (`profiles_select_staff`,
|
||||
`audit_logs_select_admin`) do not read the assurance level. AR-1 B covers
|
||||
changes of roles, not those reads; IDENTITY.md §4 foresaw folding `has_mfa`
|
||||
into them. Left for an owner decision; V1-2.1 does not change them.
|
||||
- Refused escalation attempts are not in the audit table (§5.7 order of
|
||||
checks).
|
||||
- A recent-TOTP freshness check on the role RPCs through `amr` (§5.7.3).
|
||||
- The DEV hardening of `ENVIRONMENTS.md` §3.6 becomes a precondition of M4
|
||||
on DEV (§5.7.2 step 0); the owner chooses its form.
|
||||
|
||||
---
|
||||
|
||||
@@ -1194,6 +1483,9 @@ test that fails on the current code before fixing it.
|
||||
| F14 | `can_edit_sheet` gives every owner and admin full rights on official sheets, with no capability and no MFA | l.494-510 | confirmed by reading | M4 |
|
||||
| F15 | the sheet policy reads `can_use_sheet`, whose `public` branch opens rows to every authenticated account, outside any catalogue right | l.513-526, l.1183-1190 | confirmed by reading | M4 (reader row predicate, §5.3) |
|
||||
| F16 | asset rows have no immutability trigger: a privileged UPDATE of `sha256` changes the drawing of a published version, which its fingerprint does not cover | asset table; `fingerprint.rs` | confirmed by reading | M4 (asset-row trigger), M5 (publication compares sha256) |
|
||||
| F17 | `service_role` keeps the default table privileges on `profile_roles` and `profiles` (the revokes name `public, anon, authenticated`), so a service-key session can write platform roles directly; `grant_platform_role` and `revoke_platform_role` are also granted to `service_role` without use | `20261008100200` l.247-248 and the revoke on `profile_roles`; `20261008100100` l.100 | confirmed by reading; effective grants checked on the sandbox in V1-2.1 | M4 (`REVOKE ALL` from `service_role` on both tables, `EXECUTE` revoked on the two RPCs) |
|
||||
| F18 | `withdraw_platform_role` counts active owners without a lock: two concurrent revocations of two owners can both pass the guard and leave none | `20261008100200` l.143-181 (count l.165-169) | confirmed by reading | M4 (advisory lock in both RPCs and the private functions, count on active profiles, two-session tests) |
|
||||
| F19 | `grant_platform_role` and `revoke_platform_role` do not check the assurance level (AR-1); a grant does not check that the target holds a verified factor; the private write functions trust a null actor from any session | `20261008100200` l.108-181, l.189-238 | confirmed by reading | M4 (`has_mfa()` as the second check, §5.7) |
|
||||
|
||||
### 12.2 Rust authority and SQL guards (O22)
|
||||
|
||||
@@ -1243,7 +1535,7 @@ Inventory of the current SQL checks and their fate:
|
||||
|
||||
| Id | Step | Content | Data on DEV |
|
||||
|---|---|---|---|
|
||||
| M4 `sheet_access_hardening` | V1-2.1 | `anatomical_catalog_grants` and its RPCs; `has_mfa`, `grant_active`, `caller_has`; `can_read_official_catalog` and the reader row predicate; `can_edit_sheet` redefined (F14); F1, F2, F3 (fork closed), F5, F6, F8, F9, F12 (every catalogue table), F13, F15; asset-row immutability trigger (F16); historical-sheet protection trigger (§14.2); reader column grants narrowed; personal creation and visibility changes refused | no row changes |
|
||||
| M4 `sheet_access_hardening` | V1-2.1 | `anatomical_catalog_grants` and its RPCs; `has_mfa`, `grant_active`, `caller_has`; `can_read_official_catalog` and the reader row predicate; `can_edit_sheet` redefined (F14); AR-1 B on the platform role RPCs and the private write functions (F19, §5.7), F17, F18; F1, F2, F3 (fork closed), F5, F6, F8, F9, F12 (every catalogue table), F13, F15; asset-row immutability trigger (F16); historical-sheet protection trigger (§14.2); reader column grants narrowed; personal creation and visibility changes refused | no row changes |
|
||||
| M5 `sheet_review_workflow` | V1-2.1 | version columns `revision`, `authors`, `source_version_id`, `published_review_id`, `document_fingerprint`; sheet column `working_copy_source_version_id`; revision, author and freeze triggers, the historical-sheet write rule; extended immutability guard (§6.8); rounds, comments, acknowledgments; `create_official_sheet`, `create_sheet_draft` adapted, `save_sheet_draft`, submit, withdraw, comment, acknowledge, decide, publish; `create_sheet_working_copy`; species RPCs; catalogue and version read RPCs; upload: `register_sheet_asset` extended, `confirm_sheet_asset_upload` with the storage check (F7), INSERT policy, bucket limit 2 MiB; mirror removal and status check (§12.2); superseded signatures dropped | new columns take their defaults on the equine v1 row (`revision` 0, empty author set); its document, status, number and assets unchanged; bucket limit lowered; no round, no grant |
|
||||
| M6 `sheet_verification_jobs` | V1-2.3 | worker RPCs (claim, input, complete with the verdict structure check, fail), service role only | none |
|
||||
|
||||
@@ -1261,7 +1553,7 @@ outside the document.
|
||||
| Threat | Control |
|
||||
|---|---|
|
||||
| Privilege escalation through the catalogue | default deny; rights in their own table, written by the owner only with `aal2`; `can_edit_sheet` redefined; no table privilege for API roles or the service role; security definer functions with `search_path = ''`, EXECUTE revoked from public and anon; superseded signatures dropped |
|
||||
| Escalation through platform roles | open: AR-1 (§17.2) |
|
||||
| Escalation through platform roles | AR-1 B: `aal2` on every grant and revocation of a platform role, checked in the RPCs before any role check and in the private write functions for a non-null actor; `service_role` has no table privilege and no `EXECUTE` on them; owner count race closed; first factor enrolled before the owner role is assigned (§5.7) |
|
||||
| Takeover of an admin or reviewer account | `aal2` in RPCs and in the capability branches of policies; a verified factor required before a capability is granted; deactivation, expiry and revocation cut access at the next request; two factors for the owner |
|
||||
| Recovery as a back door | no application path resets a factor; operator procedure with out-of-band identity check, capabilities revoked and sessions signed out first, an audit row (§5.6) |
|
||||
| Self-approval | author set maintained by trigger and frozen at submission; no author acknowledges or approves; empty saves refused; content writes without an actor refused |
|
||||
@@ -1285,11 +1577,20 @@ outside the document.
|
||||
|
||||
Residual risks:
|
||||
|
||||
- AR-1 until the owner decides (§17.2);
|
||||
- the token's `aal` claim outlives a factor removal for up to one token
|
||||
lifetime unless the session check of §5.7.8 is confirmed on the pinned
|
||||
image; a stolen `aal2` session can also change platform roles and replace
|
||||
factors (same residual as below);
|
||||
- a role holder who removes the last factor from `aal2` keeps the role in
|
||||
the first-factor case (§5.7.3);
|
||||
- refused escalation attempts leave no audit row (the transaction raises);
|
||||
- staff reads gated by `is_platform_admin` stay at `aal1` (§5.7.9);
|
||||
- the service key is also a GoTrue admin credential: whoever holds it can
|
||||
delete factors and sign in as anyone, so MFA does not protect against a
|
||||
service-key holder; the key stays on the server, in the worker and in the
|
||||
operator's environment;
|
||||
operator's environment, except on DEV today, where it is the public demo
|
||||
key and the JWT secret is the CLI default (`ENVIRONMENTS.md` §3.6), so
|
||||
AR-1 B is forgeable on DEV until that hardening (§5.7.2 step 0);
|
||||
- a capability does not prove a professional qualification: the owner's
|
||||
verification note is a declaration until Step 9;
|
||||
- the owner can create and habilitate a second account of its own; traced,
|
||||
@@ -1475,6 +1776,45 @@ The final approval needs all 30 groups acknowledged, no `to_confirm` and no
|
||||
- deprecated version deletion refused; D8 reads after archive and
|
||||
deprecation; superseded signatures and mirror functions absent; upgrade
|
||||
from the DEV state.
|
||||
- AR-1 B (SQL, per §5.7; PGlite sets the `aal` claim through the JWT
|
||||
settings, the `auth.sessions` check needs the real image):
|
||||
- matrix: no role, owner, admin, moderator, support, each at `aal1` and
|
||||
`aal2`, plus a deactivated account, on grant and on revoke, for each of
|
||||
the four roles, on self and on another account; expected: `aal1` always
|
||||
refused with `mfa_required`, `aal2` allowed only where
|
||||
`can_manage_platform_role` allows (owner any role, admin moderator and
|
||||
support), a moderator or support at `aal2` refused;
|
||||
- regression of the chain: an owner at `aal1` calls the grant RPC directly
|
||||
for an attacker-controlled account; refused, no `profile_roles` row, no
|
||||
audit row, no capability grantable to it; same for revoking the real
|
||||
owner and for a demotion;
|
||||
- the private functions refused for a non-null actor at `aal1`, the null
|
||||
actor path still working for the seed; `service_role` refused on the RPCs
|
||||
and on both tables (F17); the last-owner guard under two concurrent
|
||||
revocations (F18);
|
||||
- no partial write on refusal; audit row on success with no secret in it;
|
||||
- a role revoked then a call with the old token: refused at the next call;
|
||||
- an account with no role, enrolling a factor, gains nothing; a first owner
|
||||
initialised on a fresh stack in the order of §5.7.1;
|
||||
- grant to a target without a verified factor refused; a null actor from
|
||||
an API session and from `service_role` refused in the private functions;
|
||||
`aal` claim absent, null or wrongly cased refused; mutual owner
|
||||
revocation and revoke against grant in two sessions;
|
||||
- fixtures that call the role RPCs (pgTAP 004 and others, the sandbox
|
||||
`workspaces.sandbox.ts` seed owner at `aal1`) moved to `aal2` claims or to
|
||||
the operator path; the PGlite shim gains stand-ins for `auth.sessions` and
|
||||
`auth.mfa_factors` with columns checked against the pinned image;
|
||||
- V1-1 regression: workspaces, clients, animals, relations, sign-in and a
|
||||
practitioner without role unchanged; pgTAP 001 to 014 green with the
|
||||
existing identity fixtures (adapted only where they assert the old
|
||||
behaviour of the role RPCs).
|
||||
- MFA on the sandbox stack (real GoTrue): first enrolment at `aal1`, verify,
|
||||
`aal2`; second factor from `aal1` refused; removal of a verified factor
|
||||
from `aal1` refused; removal from `aal2` and the session consequences;
|
||||
password reset does not reach `aal2`; refresh keeps `aal2`; revoked session
|
||||
and old token; recovery rehearsal of §5.7.7. Expectations are what the
|
||||
pinned image really does; any gap with §5.7.3 is written up and decided by
|
||||
the owner.
|
||||
- Concurrency on the real stack, two sessions: two saves, save against
|
||||
submit, publish against withdraw, two publishers, deprecate against publish,
|
||||
completion against withdrawal.
|
||||
@@ -1505,7 +1845,8 @@ The final approval needs all 30 groups acknowledged, no `to_confirm` and no
|
||||
- Browser (`e2e:shell` on the sandbox, never DEV): journeys A0 to A8, S1, W1,
|
||||
R1, P1 with two accounts (an editor and publisher, a reviewer) plus reader
|
||||
assertions, TOTP codes generated by a test helper (Node `crypto` HMAC, no
|
||||
dependency, V1-2.5); axe; 320 to 430 px for the catalogue, 375 px for admin
|
||||
dependency, built in V1-2.1 for the real-GoTrue acceptance of §16.2 and
|
||||
reused in V1-2.5); axe; 320 to 430 px for the catalogue, 375 px for admin
|
||||
screens; FR and EN.
|
||||
- Each step: `pnpm check:all`, fresh verifier against this contract, fresh
|
||||
security audit.
|
||||
@@ -1529,7 +1870,7 @@ V1-2.1; 5 core loading and validation → V1-2.2; the server verdict → V1-2.3;
|
||||
categories, references → V1-2.6; 10 preview and validation → V1-2.7;
|
||||
11 equine → V1-2.8; 12 acceptance and closure → V1-2.9.
|
||||
|
||||
Owner checkpoints: V1-2.0 (final review of this contract, AR-1), V1-2.3
|
||||
Owner checkpoints: V1-2.0 (final review of this contract), V1-2.3
|
||||
(server workflow and verdict), V1-2.4 (wireframes), V1-2.6, V1-2.7, V1-2.8
|
||||
(with the business reviewer), V1-2.9 (closure, merge), and each DEV operation
|
||||
of §16.11.
|
||||
@@ -1546,8 +1887,8 @@ V1-2.7 on.
|
||||
- Security prerequisites: none (documents only).
|
||||
- Application changes: none. SQL changes: none.
|
||||
- Tests: documentary checks only (cross-references, ids, tables).
|
||||
- Acceptance: the owner's final review finds no contradiction; AR-1 decided;
|
||||
ratification recorded.
|
||||
- Acceptance: the owner's final review finds no contradiction; AR-1 decided
|
||||
(B, BDR-083); ratification recorded.
|
||||
- Rollback: revert the documentary commits.
|
||||
- Checkpoint: owner, final review; V1-2.1 starts only on the owner's go.
|
||||
|
||||
@@ -1560,7 +1901,7 @@ V1-2.7 on.
|
||||
the historical-sheet protection; the upload RPCs and policy; removal of the
|
||||
SQL mirror and the status check; `packages/supabase/src/sheets.ts` with
|
||||
closed failure kinds; the client gate deleted.
|
||||
- Dependencies: V1-2.0 go, AR-1 decided.
|
||||
- Dependencies: V1-2.0 go; AR-1 B decided (BDR-083).
|
||||
- Security prerequisites: effective grants of the service role recorded on
|
||||
the sandbox before F12's fix; census of private functions updated (pgTAP
|
||||
001); every RPC requires `aal2` except the reader RPCs.
|
||||
@@ -1578,6 +1919,12 @@ V1-2.7 on.
|
||||
working copy created from the seeded historical sheet with its drawing; an
|
||||
inactive species invisible to the animal path; types check clean; `pnpm
|
||||
check:all` green.
|
||||
- Acceptance, AR-1 B: the tests of §15 for §5.7 pass on the sandbox; a
|
||||
stack upgraded from the DEV state with an owner holding two verified
|
||||
factors keeps working at `aal2` and is refused at `aal1`; the same upgrade
|
||||
with an owner holding none stays usable at `aal1` for everything but role
|
||||
and rights management; the census lists no other write path to
|
||||
`profile_roles`.
|
||||
- Rollback: branch revert; sandbox rebuilt.
|
||||
- Checkpoint: gates only (owner at V1-2.3).
|
||||
|
||||
@@ -1647,12 +1994,17 @@ V1-2.7 on.
|
||||
- Security prerequisites: server rules of V1-2.1 in place; the UI is never
|
||||
the boundary.
|
||||
- Application changes: routes and screens of §11.1 except the editor and the
|
||||
review screen; Mon compte, Sécurité; the TOTP test helper. SQL changes:
|
||||
none.
|
||||
review screen; Mon compte, Sécurité; the TOTP test helper (from V1-2.1). SQL changes:
|
||||
none. Scope split: M4 (V1-2.1) holds every server control of AR-1 B; this
|
||||
step holds the frontend journey only (enrolment, step-up, factor list, the
|
||||
`mfa_required` message in FR and EN).
|
||||
- Tests: unit; `e2e:shell` A0, A1, S1, P1; access per right; MFA required;
|
||||
refresh keeps `aal2`; no `aal1` enrolment of a second factor; axe; 320 to
|
||||
430 px for the catalogue, 375 px for admin screens; FR/EN.
|
||||
- Acceptance: the owner with MFA grants rights and creates a sheet; an editor
|
||||
- Acceptance: the owner enrols two factors from Mon compte, reaches `aal2`,
|
||||
and only then manages platform roles and rights (an `aal1` attempt is
|
||||
refused in the UI and in SQL); the owner with MFA grants rights and creates
|
||||
a sheet; an editor
|
||||
creates an inactive species that the animal forms do not show until the
|
||||
owner activates it; a sheet published on the sandbox through SQL fixtures
|
||||
is browsable by a catalogue reader and refused to a confirmed account
|
||||
@@ -1748,8 +2100,12 @@ V1-2.7 on.
|
||||
Each is an owner action, never run by Claude, after its own checkpoint:
|
||||
|
||||
1. applying M4 to M6, after a backup and a sandbox rehearsal from the DEV
|
||||
state;
|
||||
2. enrolling the owner's two TOTP factors and the first rights grants;
|
||||
state; M4 is not applied before the preconditions of §5.7.2 (DEV hardening
|
||||
of `ENVIRONMENTS.md` §3.6, seed owner password, role holders listed,
|
||||
item 2's factors enrolled and verified), nor before the recovery of §5.7.7 is rehearsed; M4's checks take
|
||||
effect when it is applied, with no flag that could be left open;
|
||||
2. enrolling the owner's two TOTP factors (before item 1, §5.7.2) and the
|
||||
first rights grants (after it);
|
||||
3. starting the verification worker on DEV: a separate operating checkpoint
|
||||
that first inventories the queues (the avatar upload waiting since
|
||||
AVATAR-01, the due purge rows, quarantine leftovers), states the expected
|
||||
@@ -1757,7 +2113,7 @@ Each is an owner action, never run by Claude, after its own checkpoint:
|
||||
4. creating, activating or renaming a species;
|
||||
5. creating the equine working copy and applying the O18 corrections;
|
||||
6. any submission, approval, publication, deprecation or archive;
|
||||
7. any factor reset (§5.6) and any `object_conflict` deletion (§9.3);
|
||||
7. any factor reset (§5.6, §5.7.7) and any `object_conflict` deletion (§9.3);
|
||||
8. rerunning the equine seed.
|
||||
|
||||
### 16.12 Deferred (not V1-2)
|
||||
@@ -1777,7 +2133,7 @@ registry in any build that can be rolled back to; V1-2 does not resolve it.
|
||||
|
||||
---
|
||||
|
||||
## 17. Ratified decisions and open arbitration
|
||||
## 17. Ratified decisions and arbitration
|
||||
|
||||
### 17.1 Ratified decisions O1 to O23
|
||||
|
||||
@@ -1789,7 +2145,7 @@ which would have accepted a browser verdict or deferred MFA, are rejected.
|
||||
| O1 | A + D: three explicit capabilities (`sheet_editor`, `sheet_reviewer`, `sheet_publisher`), granted and revoked by the owner; editor and publisher need a platform role owner or admin; reviewers may be confirmed non-admin accounts; every grant audited, with a required reason, a verification note, a date and an optional expiry; e-mail confirmation is no proof of competence | §5.1, §5.2 |
|
||||
| O2 | A: no author acknowledges or approves; author set frozen at submission and checked on the server; two people suffice; the publisher may be the approver; no silent override for a sole owner | §5.5 |
|
||||
| O3 | B: no `to_confirm` and no `inherited` (absent statuses included) at approval or publication; the historical import is never a base; new elements start `to_confirm`; changes re-open coverage | §6.6, §6.7, §14 |
|
||||
| O4 | A: `aal2` for every catalogue operation except reading the published catalogue; enrolment, step-up, sessions, loss and operator recovery documented; O4-D evaluated, not ratified, now the subject of AR-1 | §5.6, §17.2 |
|
||||
| O4 | A: `aal2` for every catalogue operation except reading the published catalogue; enrolment, step-up, sessions, loss and operator recovery documented; O4-D evaluated, not ratified at the time; the arbitration AR-1 then extended `aal2` to every platform role change (§17.2) | §5.6, §5.7 |
|
||||
| O5 | A: one approval closes a round; trace kept for a future quorum | §6.3 |
|
||||
| O6 | A: scope disclaimer required, present in FR and EN and non-blank after trimming; equine texts untouched | §6.7 |
|
||||
| O7 | A: new elements start `to_confirm`; nothing assigns `reviewed` or `inherited` automatically; draft state, element marking and business approval distinguished | §6.6 |
|
||||
@@ -1810,33 +2166,30 @@ which would have accepted a browser verdict or deferred MFA, are rejected.
|
||||
| O22 | Rust core the only authority on document rules; SQL keeps access, relations, states, revisions, locks, atomicity and the verdict's identity; the business mirror is removed in M5 without an unprotected window; one declared status check kept | §12.2 |
|
||||
| O23 | Fail-closed verification: explicit states and outcomes, closed codes per category, idempotent retries under a limit, withdrawal always possible, audit, no partial publication | §6.5 |
|
||||
|
||||
### 17.2 Open arbitration AR-1: MFA on platform role grants (O4-D)
|
||||
### 17.2 Arbitration AR-1: MFA on platform role changes (ratified, option B)
|
||||
|
||||
Finding (security challenge, §19.3, confirmed by reading
|
||||
`20261008100200_platform_roles.sql` l.83-95 and l.189-238): an owner may grant
|
||||
any platform role, owner included, and `grant_platform_role` does not check the
|
||||
assurance level. From a stolen owner session at `aal1` (password only), an
|
||||
attacker grants `owner` to an account of their own; that account enrols its
|
||||
own TOTP factor, reaches `aal2`, grants itself every capability (§5.2) and a
|
||||
reviewer capability to a third account, then may revoke the real owner. Every
|
||||
`aal2` control of the catalogue is bypassed. O4-D (extending `aal2` to these
|
||||
RPCs) was explicitly left unratified, so this contract cannot close the gap on
|
||||
its own.
|
||||
`20261008100200_platform_roles.sql`, the two RPCs): an owner could grant any
|
||||
platform role, owner included, with no check of the assurance level. From a
|
||||
stolen password-only owner session, an attacker grants a role to an account
|
||||
of their own, which enrols its own factor, reaches `aal2` and grants itself
|
||||
every catalogue capability; every `aal2` control of the catalogue was
|
||||
bypassed. The chain is written out in §5.7.
|
||||
|
||||
Options for the owner:
|
||||
Options put to the owner: A (`aal2` for `owner` and `admin` only), B (`aal2`
|
||||
for every platform role), C (leave the RPCs and accept the residual).
|
||||
|
||||
- A (recommended): ratify O4-D at least for granting and revoking `owner` and
|
||||
`admin`, the roles that make an account eligible for `sheet_editor` and
|
||||
`sheet_publisher`: `has_mfa()` in `grant_platform_role` and
|
||||
`revoke_platform_role` for those roles, in M4, with pgTAP cases. Cost: one
|
||||
predicate; it changes a V1 identity contract and requires the owner's
|
||||
session at `aal2` to manage those roles.
|
||||
- B: ratify O4-D for every platform role. Same cost, broader.
|
||||
- C: keep the RPCs unchanged and accept the residual explicitly. Then the
|
||||
catalogue's MFA protects against a stolen editor or reviewer password, not
|
||||
against a stolen owner password.
|
||||
Decision (owner, 2026-10-28, BDR-083): **B**. Every grant, revocation or
|
||||
change of a platform role requires a valid `aal2` session checked on the
|
||||
server, with no permanent exception. It complements O4 and leaves D1 to D9
|
||||
and O1 to O23 unchanged (O1, O2 and O4 are applied, not amended: a role gives
|
||||
no capability, `aal2` replaces no permission, §5.2, §5.5, §5.7). Where it
|
||||
lands: rule, inventory, bootstrap, recovery and session rules in §5.7; M4 in
|
||||
§12.3 (F17, F18, F19); tests in §15; acceptance in §16.2, §16.6; the order of
|
||||
DEV operations in §16.11.
|
||||
|
||||
Until the owner chooses, V1-2.1 does not start (§16.2).
|
||||
Reserves left to the owner, not decided here: `aal2` on the staff read
|
||||
policies (§5.7.9).
|
||||
|
||||
---
|
||||
|
||||
@@ -1855,7 +2208,7 @@ First revision (2026-10-27):
|
||||
Consolidation (2026-10-28):
|
||||
|
||||
- this file: decisions ratified, contradictions resolved, steps restated,
|
||||
second challenge round integrated, AR-1 open;
|
||||
second challenge round integrated, AR-1 decided (B) and integrated in §5.7;
|
||||
- `docs/development/IMPLEMENTATION_PLAN.md`: §0 roadmap row of V1-2, Steps 13
|
||||
and 17 notes (editor scope moved into V1-2 for official sheets), Step 13's
|
||||
stale `content_jsonb`;
|
||||
@@ -1873,6 +2226,15 @@ Consolidation (2026-10-28):
|
||||
- `.claude/tasks/TODO.md`, `.claude/memory/decisions.md` (BDR-082),
|
||||
`.claude/memory/journal.md`.
|
||||
|
||||
AR-1 B integration (2026-10-28):
|
||||
|
||||
- this file: §5.7 (rule, scenario, inventory, bootstrap, factors, password,
|
||||
recovery, sessions), F17 to F19, M4, tests, steps and DEV order, §17.2
|
||||
closed;
|
||||
- `.claude/memory/decisions.md` (BDR-083), `.claude/tasks/TODO.md`,
|
||||
`.claude/memory/journal.md`;
|
||||
- `docs/development/IDENTITY.md` §4: one pointer to §5.7, no other change.
|
||||
|
||||
Not touched, with stale `content_jsonb` mentions left for V1-2.9:
|
||||
`BACKEND_ARCHITECTURE.md` l.110, `DOMAIN_MAP.md` l.119.
|
||||
|
||||
@@ -1926,3 +2288,12 @@ repository before being integrated; none changed a ratified decision.
|
||||
| Business coherence | CONCERNS (3 major, no blocker, no arbitration) | Acknowledgments voided by the later marking, so every equine group acknowledged twice (protocol « editor marks, then reviewer acknowledges », acknowledgment refused on groups with unread elements, §6.3, §14.6); removed zone or view had no group to cover (removal groups); working copy slot blocked by an archived copy (only `active` copies count); anatomical decisions carried out by editors from reviewer comments (§14.5); grant expiry and renewal semantics (§5.2); owner missing from the species list (§5.4); round columns per state (§6.3); base from deprecated or pre-V1-2 versions (base only from a V1-2-published version, §6.2); deprecating the last published version (§6.9); DEV copy as the single source of truth, sandbox copies as rehearsals (§14.4); cleaning table misdescribed the reader (§9.2); `published_by` already exists (M5); O6 « structure » defined; active species names (owner renaming) |
|
||||
| Security and data | FATAL (1 blocker as arbitration request, 6 major) | AR-1: an `aal1` owner session grants the owner role and bypasses every catalogue MFA control (§17.2, open); the defensive status check could not see omitted statuses (structural walk, absent = `inherited`, §12.2); service-role privileges and direct publication (F12 unconditional, guard requires an approved round with a passed verdict, asset-row immutability F16, sha256 compared at publication, GoTrue residual in §13); readers could list draft-only sheets through the `public` branch (reader row predicate, F15); historical sheet deletable or archivable (RPC refusals and trigger, §14.2); poisoned content-addressed key without exit (`object_conflict` runbook with an audited scoped deletion, earlier detection by `PreviewSheet`, §9.3); first-factor trust on first use (verified factor required before a capability, recovery revokes and signs out first, `aal1` enrolment test); minor: serialised size, worker body cap, base from legacy publications, verdict structure checked in SQL, predicates split by caller and stored actor, signed URLs (residual), cleaning fixpoint |
|
||||
| Simplicity and feasibility | CONCERNS (5 major, no arbitration) | Editor step waited for the worker step (uploads moved to M5, editor independent of V1-2.3, verification passing moved to V1-2.7); worker changes understated (separate verification mode and container, per-command limits, avatar lease reused without backoff, sandbox worker a deliverable); no editor render path (`PreviewSheet` as the editor handle with document replacement and `view.canvas`); overlapping coverage rules (one rule on group digests, change list for display only, no earlier digests sent to the worker); status check blind to omitted statuses (fixed as above); minor: core step ordered verdict first; level 1 trimmed (no move to another parent, no dragged vertices, numeric crop); two cleaning classes; rules epoch replaced by release migrations withdrawing rounds; two failure outcomes with categorised codes; comments with a group key only; time budgets and named fixtures; TOTP test helper; `register_sheet_asset` extended instead of a new RPC; purge guard by bucket. Not taken: moving the working copy RPC to V1-2.8 (it stays in M5 so DEV receives one set of migrations) |
|
||||
|
||||
### 19.4 AR-1 B review (2026-10-28)
|
||||
|
||||
One fresh challenger (robustness and security lens) read the AR-1 B text
|
||||
against the migrations, the seed, the PGlite shim and `ENVIRONMENTS.md`.
|
||||
|
||||
| Lens | Verdict | Findings and what changed |
|
||||
|---|---|---|
|
||||
| Security | FATAL (1 blocker, 3 major, 6 minor) | DEV signs tokens with the public default secret and exposes 54321 to the LAN, so `aal2` is forgeable there (precondition §5.7.2 step 0, §16.11, §13 corrected); a grant to an account without a factor reopened the chain (target factor required, check 5); seed owner with a committed password and re-seed after M4 (password change or new owner, reset reopens the preconditions, seed declared a local-fixture exception); recovery runbook unrunnable under a ban and silent on the owner's capabilities (reordered, capabilities inert at `aal1`); minor: unverified factors, null actor keyed on the argument, owner race beyond the count and on inactive profiles, `amr` freshness overclaim, session-check fallback made a stop, sign-out wording, API-log claim, harness gaps (shim, fixtures, TOTP helper moved to V1-2.1), cross-references. None changed a ratified decision |
|
||||
Reference in new issue
Block a user