[H-7] Unbounded Mnesia growth: token rows (full JWT strings), certificate_request rows, login_attempt rows never purged #11

Closed
opened 2026-11-14 18:28:44 +01:00 by amiryahaya · 0 comments
Owner

Finding

:oauth_access_token stores the entire signed JWT per issuance and is never read or deleted. :certificate_request rows live forever (only 'cleanup' is the table-wiping script 11). :login_attempt rows for never-retried identifiers persist forever; attackers churning client_ids create unlimited rows.

Evidence

  • lib/mdid_ws/oauth/token.ex:124-136 — full JWT stored, zero deletions anywhere
  • lib/mdid_ws/auth/rate_limiter.ex:92-104 — row per unique ip:client_id
  • scripts/11_clear_cert_requests.sh — wipes the whole table

Impact

Persistent disc exhaustion on the CA volume; amplifies the scan cost in H-6.

Fix

  • Periodic sweeper (GenServer/Process.send_after) deleting expired tokens (expires_at is already stored) and stale login attempts
  • Store only a token hash, not the full JWT, if the row is only for tracking
  • Define an archival policy for certificate_request

Line numbers refer to the initial import commit 282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).

## Finding `:oauth_access_token` stores the entire signed JWT per issuance and is never read or deleted. `:certificate_request` rows live forever (only 'cleanup' is the table-wiping script 11). `:login_attempt` rows for never-retried identifiers persist forever; attackers churning client_ids create unlimited rows. ## Evidence - `lib/mdid_ws/oauth/token.ex:124-136` — full JWT stored, zero deletions anywhere - `lib/mdid_ws/auth/rate_limiter.ex:92-104` — row per unique ip:client_id - `scripts/11_clear_cert_requests.sh` — wipes the whole table ## Impact Persistent disc exhaustion on the CA volume; amplifies the scan cost in H-6. ## Fix - [ ] Periodic sweeper (GenServer/`Process.send_after`) deleting expired tokens (expires_at is already stored) and stale login attempts - [ ] Store only a token hash, not the full JWT, if the row is only for tracking - [ ] Define an archival policy for certificate_request _Line numbers refer to the initial import commit `282cb11`. Source: comprehensive audit, 2026-11-12 (first review of this codebase)._
Sign in to join this conversation.
No description provided.