#4 (CRIT-4): refuse silent CA regeneration when issued certificates exist; prod bootstrapping requires explicit opt-in #46

Merged
amiryahaya merged 1 commit from fix/crit-4-bootstrap-guard into main 2026-11-14 19:28:13 +01:00
Owner

A lost/partial Mnesia volume made ensure_issuers/0 silently generate a brand-new Root/Sub/OCSP hierarchy and keep issuing — orphaning every previously issued certificate (broken chains, dangling OCSP/CRL/AIA) with no alarm.

Changes

  • verify_ca_bootstrap_allowed!/0 runs before any generation: raises when certificate_request rows exist without a Root CA (any env), and requires MDID_BOOTSTRAP_CA=true in :prod even for a fresh store
  • pure decision logic in ca_bootstrap_allowed?/2
  • integration test with real subprocess nodes: fresh dir bootstraps → issuer-table loss + issued certs → next boot refuses with an actionable message
  • compose + .env.example document MDID_BOOTSTRAP_CA (default false)

Full suite: 180 passed locally.

Fixes #4

A lost/partial Mnesia volume made `ensure_issuers/0` silently generate a brand-new Root/Sub/OCSP hierarchy and keep issuing — orphaning every previously issued certificate (broken chains, dangling OCSP/CRL/AIA) with no alarm. **Changes** - `verify_ca_bootstrap_allowed!/0` runs before any generation: raises when `certificate_request` rows exist without a Root CA (any env), and requires `MDID_BOOTSTRAP_CA=true` in :prod even for a fresh store - pure decision logic in `ca_bootstrap_allowed?/2` - integration test with real subprocess nodes: fresh dir bootstraps → issuer-table loss + issued certs → next boot refuses with an actionable message - compose + `.env.example` document `MDID_BOOTSTRAP_CA` (default false) Full suite: 180 passed locally. Fixes #4
fix(ca): refuse silent CA hierarchy regeneration when certificates exist
All checks were successful
Lint / lint (pull_request) Successful in 2m34s
Security / Dependency advisories (mix hex.audit) (pull_request) Successful in 30s
Security / Secret scan (gitleaks) (pull_request) Successful in 10s
Unit tests / test (pull_request) Successful in 3m11s
9ac8786d18
A lost/partial Mnesia volume previously made ensure_issuers/0 silently
generate a brand-new Root/Sub/OCSP hierarchy and keep issuing — orphaning
every previously issued certificate (broken chains, dangling OCSP/CRL/AIA)
with no alarm.

- verify_ca_bootstrap_allowed!/0 runs before any generation: raises when
  certificate_request rows exist without a Root CA (any environment), and
  requires MDID_BOOTSTRAP_CA=true in :prod even for a fresh store
- pure decision logic extracted as ca_bootstrap_allowed?/2
- integration test boots real subprocess nodes: fresh dir bootstraps,
  issuer-table loss + issued certs refuses with a actionable message
- compose + .env.example document MDID_BOOTSTRAP_CA (default false)

Fixes #4 (audit CRIT-4)
Sign in to join this conversation.
No description provided.