[CRIT-4] Silent CA regeneration on empty/partial Mnesia volume orphans every previously issued certificate #4

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

Finding

ensure_issuers/0 regenerates a brand-new Root→Sub→OCSP hierarchy whenever the issuer table is missing — lost volume, partial restore, or corruption all trigger it, and the service silently continues issuing under the new CA. Related: DNSCluster is wired for prod while Mnesia is single-node disc_copies — a second node would bootstrap its own Root (split-brain CAs).

Evidence

  • lib/mdid_ws/application.ex:107-139 — ensure_issuers/0 regenerate-if-missing
  • lib/mdid_ws/application.ex:18 + config/runtime.exs:63 — DNSCluster vs single-node Mnesia

Impact

All existing leaf certs stop chaining; OCSP/CRL/AIA URLs dangle; no alarm. Worst integrity failure mode available to a CA.

Fix

  • Refuse to bootstrap a new CA when certificate_request is non-empty (log at :error and halt)
  • Require explicit opt-in (e.g. MDID_BOOTSTRAP_CA=true) for fresh CA generation
  • Resolve or remove the DNSCluster/single-node Mnesia contradiction before ever scaling out

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

## Finding `ensure_issuers/0` regenerates a brand-new Root→Sub→OCSP hierarchy whenever the issuer table is missing — lost volume, partial restore, or corruption all trigger it, and the service silently continues issuing under the new CA. Related: DNSCluster is wired for prod while Mnesia is single-node `disc_copies` — a second node would bootstrap its own Root (split-brain CAs). ## Evidence - `lib/mdid_ws/application.ex:107-139` — `ensure_issuers/0` regenerate-if-missing - `lib/mdid_ws/application.ex:18` + `config/runtime.exs:63` — DNSCluster vs single-node Mnesia ## Impact All existing leaf certs stop chaining; OCSP/CRL/AIA URLs dangle; no alarm. Worst integrity failure mode available to a CA. ## Fix - [ ] Refuse to bootstrap a new CA when `certificate_request` is non-empty (log at :error and halt) - [ ] Require explicit opt-in (e.g. `MDID_BOOTSTRAP_CA=true`) for fresh CA generation - [ ] Resolve or remove the DNSCluster/single-node Mnesia contradiction before ever scaling out _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.