HIGH - Enables field-overflow attacks on ZK circuits
Detects circuit signals/inputs used in arithmetic or comparisons without accompanying range-check constraints, allowing attackers to exploit field overflow to bypass validation logic.
// ❌ BAD: No range constraint
signal input amount;
signal input balance;
signal output isValid;
// Field overflow possible - amount could be negative in field arithmetic!
isValid <== amount < balance;Attack: Attacker provides amount = p - 1 (where p is field modulus), which wraps to -1, bypassing the check.
// ✅ GOOD: Range check enforced
signal input amount;
signal input balance;
signal output isValid;
// Ensure amount is in valid range (64 bits)
component amountCheck = Num2Bits(64);
amountCheck.in <== amount;
component balanceCheck = Num2Bits(64);
balanceCheck.in <== balance;
// Now safe to compare
isValid <== amount < balance;Under-constrained circuits are the #1 finding in ZK audits. Field overflow allows:
- Bypassing balance checks (send more than you have)
- Manipulating age/time constraints
- Breaking merkle proof validation
- Forging identity credentials
Requires circom/Noir circuit source parsing (#1227):
- Parse circuit and build signal dataflow graph
- Find signals used in arithmetic (
+,-,*,/) or comparisons (<,>,==) - Check for preceding range-check templates:
- Circom:
Num2Bits,LessThan,RangeCheck - Noir:
assert_max_bit_size, range constraints
- Circom:
- Flag unconstrained signals
- #1227: Circom parser integration (BLOCKS THIS RULE)
- #1192, #1194: ZK infrastructure
When invoked with --deep-verify, Sanctifier translates the circuit constraint
set into Z3 SMT assertions and checks whether each signal used in a comparison
is provably bounded (see smt::circuit_range and ADR-006).
This is an optional, computationally expensive pass that goes beyond heuristic pattern matching to provide a formal proof of under-constrained signals.
- Under-Constrained Circom Circuits
- ZK Circuit Auditing Guide
- ADR-011: Formal-Verification Scope for ZK Contracts
See fixtures after #1227 integration.