Vault hardening — persist a canonical master-key verifier (authenticated ground truth) #1
Loading…
Add table
Add a link
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?
Title: Vault hardening — persist a canonical master-key verifier (authenticated ground truth)
Labels: security, enhancement, deferred
Summary
ITFlow's credential vault has no authenticated site master key. Every path (web
login, admin API-token creation, and the Phase 3 credential-login vault bootstrap)
recovers the master key by unauthenticated AES-CBC decryption of a per-user
"wrap". AES-CBC does not fail on a wrong key — it returns garbage that can
occasionally pass a shape check. There is no MAC anywhere to confirm "this is the
real master key."
Impact
If a user's stored wrap becomes inconsistent with their password — realistically
after an admin force-resets that user's password without re-wrapping their
user_specific_encryption_ciphertext, or a DB restore/edit — then login recoversa wrong-but-valid-shaped master. If a write then proceeds under it, the new
credential is encrypted with a junk key and is permanently unreadable. Reads are
non-destructive (garbage just fails to decrypt).
Current mitigation (shipped, Phase 3)
api/v2/auth/login.phpprovisions credential-session vault access only when therecovered master's HMAC matches the verifier stored on a manual admin token
(
auth_site_master_verifier()inapi/v2/auth/includes/vault_wrap.php), which wascreated from an admin's live web session. This blocks the realistic path (a
reset user's stale wrap won't match). The residual gap: the admin token's own
verifier is itself derived from an unvalidated decrypt, so if the admin's own wrap
were stale the ground truth would be wrong (self-evident — the admin's web vault
would be broken).
Proper fix (this issue)
(
setup/index.php,scripts/setup_cli.php), also persistHMAC('itflow-...-master', master)as an immutable canonical verifier(fork-owned storage: a small additive table or settings column).
from the admin's live in-use session master (corroborated by the admin
actively reading the vault). Fail closed (no write-capable vault) until seeded.
hash_equals(canonical_verifier, HMAC(recovered_master)). Manual-tokencreation validates against the canonical verifier and never establishes or
replaces it.
Additive, no re-encryption, no key change, no re-setup — but it does touch core
setup files, so it was deferred (2026-07-15) to keep core changes minimal.
References
docs/AUTH-VAULT-PHASE3.md§3, §4bfunctions.php(setupFirstUserSpecificKey / decryptUserSpecificKey),admin/post/api_tokens.php:77-99,api/v2/credentials.php