Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 2.32 KB

Z010.md

File metadata and controls

62 lines (43 loc) · 2.32 KB

Z010 — Missing Access Control on Verifying-Key Rotation / Upgrade

Category: zk-access-control
Severity: Critical
Rule name: unprotected_vk_rotation


What it detects

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.


Why it matters

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.


Vulnerable example

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);
}

Safe example

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);
}

Kani Formal Proof

The VK-rotation implementation in contracts/zk-verifier/ has Kani harnesses proving three invariants:

  1. No rotation completes without quorum — approval_count < threshold always blocks.
  2. No rotation completes before the timelock elapses — now < unlock_at always blocks.
  3. Cancel always prevents a pending rotation from completing — executed || cancelled always blocks.

See contracts/zk-verifier/src/vk_storage.rs and ADR-011 for scope boundaries.

References