Record administrator failed attempts without storing credentials

Rejected administrator authentication and authorization attempts are now
recorded durably in a new additive admin_attempts table with a fixed reason
(invalid_key_format, unknown_or_disabled_key, missing_session,
unknown_or_expired_session, role_denied), the attempt kind, the attempted role
and an already-known account id. No key, key hash, session token, session hash,
request body, origin, address or user agent is stored, and the
unknown/disabled distinction is deliberately collapsed so the lookup cannot
become an account-enumeration oracle.

GET /api/admin/operations?attempts=1 returns seven-day per-reason counters plus
the twenty most recent attempts, newest first, to a live owner only, with
no-store and the same query guard as the other reads. The operations page adds
"List failed attempts" with the counters and the bounded sample, truncating each
account id to eight characters. Recording is best-effort inside the rejection
path, so a rejected request keeps its own answer even when the table is
unavailable, and the history never locks out, disables or revokes anything by
itself.

Evidence: tests/admin-attempts.test.ts asserts every recorded reason, the
kind/role/account fields, that successful sign-ins and privileged reads record
nothing, that no credential text appears anywhere in the page, the reporting
window, the twenty-row bound and the owner-only recheck after demotion, and that
a dropped attempts table leaves the original rejection answer unchanged. The
anonymous HTTP boundary denies ?attempts=1, and the panel was verified in the
real browser against a genuine recorded rejection. The shared AdminError moved
to db/admin-error.ts so the recorder and the access module no longer form a
value-import cycle. Offline suite 7,801/7,801 with typecheck and lint clean. No
game, seat, saved state or deployment changes.
This commit is contained in:
Quintine committed 2026-10-07 19:11:45 +11:00
1 parent 3bebc68cd5
commit 8bea4c1a0c
15 files changed
+3090 -21

No files matched your search

+10 -1
View File
@@ -74,6 +74,15 @@ eligibility and Tleilaxu income repeat scope stay gated exactly as recorded in
[TLEILAXU_AMBASSADOR_RULES.md](TLEILAXU_AMBASSADOR_RULES.md#implementation-decision-boundary);
no ordinary revival allowance, price, phase or income path changed.
**In progress — administrator failed-attempt history.** Rejected administrator
authentication and authorization attempts are now recorded durably with a fixed
reason, the attempted role and an already-known account id — never a key, token,
body or address — and the owner-only operations page lists seven-day per-reason
counters plus the twenty most recent entries. Recording is best-effort inside
the rejection path, so a rejected request keeps its own answer, and the history
never locks out, disables or revokes anything by itself. See
[ADMIN_ATTEMPTS.md](ADMIN_ATTEMPTS.md).
**In progress — administrator operations.** The owner-only operations page now
also diagnoses [stalled decisions](ADMIN_STALLED_DECISIONS.md): a bounded,
read-only sample of at most ten live rooms whose public pending interaction — a
@@ -82,7 +91,7 @@ decision, response, Truthtrance or phase opening — has been idle longest, plus
Paused, closed, removed and archived rooms are excluded and no private game
content is selected; `GET /api/admin/operations?stalled=1` stays owner-only,
`no-store` and read-only, and it repairs nothing. Failed-attempt records, disk
capacity and maintenance controls remain.
Disk capacity and maintenance controls remain.
**Mixed E1/E2 and paired E3 Nexus — bounded Development Verified.**