Category: zk-access-control
Severity: Critical
Rule name: unprotected_vk_rotation
A function that writes a new verifying key (or trusted-setup parameter) to persistent storage without a preceding require_auth() call on a privileged admin or a multi-sig guardian address.
The verifying key is the cryptographic root of trust for all proofs the contract accepts. An unprotected rotation function lets any caller replace the key with one they generated, after which they can produce valid proofs for any false statement — minting tokens at will, bypassing nullifier checks, or proving ownership of assets they do not hold. This is equivalent to an unprotected set_admin (S001) but with no on-chain evidence of the compromise.
pub fn set_verifying_key(env: Env, new_vk: BytesN<64>) {
// Z010: anyone can replace the verifying key — no auth check.
env.storage().persistent().set(&DataKey::VerifyingKey, &new_vk);
}pub fn set_verifying_key(env: Env, new_vk: BytesN<64>) {
let admin: Address = env.storage().persistent().get(&DataKey::Admin)
.expect("not initialized");
admin.require_auth();
env.storage().persistent().set(&DataKey::VerifyingKey, &new_vk);
// Update integrity hash so Z005 checks remain consistent.
let new_hash = env.crypto().sha256(&Bytes::from_slice(&env, new_vk.as_ref()));
env.storage().persistent().set(&DataKey::VkHash, &new_hash);
}The VK-rotation implementation in contracts/zk-verifier/ has Kani harnesses
proving three invariants:
- No rotation completes without quorum —
approval_count < thresholdalways blocks. - No rotation completes before the timelock elapses —
now < unlock_atalways blocks. - Cancel always prevents a pending rotation from completing —
executed || cancelledalways blocks.
See contracts/zk-verifier/src/vk_storage.rs and ADR-011 for scope boundaries.