Files
OpenViking/tests/unit/crypto
Zayn Jarvis 0ea5815748 fix(crypto): 禁止重写 Vault root key on 临时 (503) read failures (#3423)
* fix(crypto): never overwrite Vault root key on transient read failures

Sweep finding B-01

* fix(crypto): clear cached ephemeral root key when Vault persist fails

The InvalidPath create branch cached the freshly generated root key in
self._root_key before encrypting/persisting it. If _encrypt_with_vault or
the KV write failed (transient transit/KV outage), get_root_key raised but
left the never-persisted key cached, so a retry returned it via the
`self._root_key is not None` fast path and encrypted data with a key that
vanishes on restart — the data-loss class this provider guards.

Wrap encrypt+persist in one try and null the cache before raising; add a
regression asserting the cache is cleared and the next call re-reads Vault.

Addresses the blocking review finding on #3423.
2026-07-24 17:30:34 +08:00
..