[CRIT-3] CA private keys (Root/Sub CA, OCSP responder, JWT JWK) stored unencrypted as Erlang terms in Mnesia disc files #3
Labels
No labels
architecture
code-quality
correctness
critical
docs
high
low
medium
ops
performance
privacy
security
tests
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
antrapol/CA-MDID-eMudhra#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
All key material is
term_to_binary'd straight into Mnesiadisc_copiesfiles on the Docker volume. No encryption at rest, no HSM, no key wrapping, Root CA key kept online — and (see CRIT-4 / M-18) with no backup story, the material has exactly one fragile copy.Evidence
lib/mdid_ws/cert_management/issuer_manager.ex:228-240— rawkeypairstored asprivate_keylib/mdid_ws/cert_management/issuer.ex:44-72—dirty_writeof issuer record incl. private keylib/mdid_ws/oauth/token.ex:146-154— JWT signing JWK asterm_to_binaryImpact
Read access to the volume, a backup, or the host filesystem = Root CA private key = 25 years of forgery (Sub CAs, leaf certs, OCSP responses).
Fix
Line numbers refer to the initial import commit
282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).Closing the audit item with one gap accepted. Done: all stored private keys (Root, Sub CA, OCSP responder, JWT signing key) are AES-256-GCM encrypted under MDID_KEY_ENCRYPTION_KEY (A6); key rotation and the compromise runbook are in docs/key-management.md. Accepted gap: the Root CA key still sits on the host (it is used once, to sign the Sub CA at bootstrap), and anyone who can read the running process also has the master key. Reason: the Trustgate part of this service is going to be replaced by another CA system, and the local Root/Sub CA signing path will be reworked with it. Revisit then: keep Root offline or out of the store, and decide where the Sub CA signing key lives (HSM/KMS) as part of the new CA integration.
Reopening: my closing comment gave the wrong reason. I said the Root key would be revisited as part of the new CA integration, but the integration is scoped to replacing Trustgate with emCA only; local signing, CRL and OCSP stay. So the local Root and Sub CA, and the accepted gap below, remain. Status: all stored private keys are AES-256-GCM encrypted under MDID_KEY_ENCRYPTION_KEY and the rotation/compromise runbook is in docs/key-management.md. Still open: the Root CA key sits on the host although it is used once, to sign the Sub CA at bootstrap, and an attacker who can read the running process also has the master key. Candidate next step: keep the Root key offline (export and wipe the key only, keep the Root certificate row; the boot guard refuses to start if the Root row is deleted while issued certificates exist), and decide separately whether the Sub CA key needs an HSM or KMS.