Aztec 2.0: Missing Bit Length Check / Nondeterministic Nullifier

From WEB3 Vulnerapedia
Jump to navigation Jump to search

Aztec 2.0: Missing Bit Length Check / Nondeterministic Nullifier

Identified By: Aztec Team

Funds in the Aztec protocol are held in what are called “note commitments”. Once a note commitment is spent, it should not be possible to spend it again. However, due to a missing bit length check, an attacker could spend a single note commitment multiple times.

Background

Whenever a new note commitment is created, it is stored in a merkle tree on-chain. In order to prevent Double-spending of a single note commitment, a nullifier is posted on-chain after the note is spent. If the nullifier was already present on-chain, then the note cannot be spent.

The Vulnerability

The nullifier generation process should be deterministic so that the same nullifier is generated for the same note commitment every time. However, due to a missing bit length check, the process was not deterministic. The nullifier was generated based on the note commitment index in the merkle tree. The code assumed the index to be a 32 bit number, but there was no constraint enforcing this check.

An attacker could use a number larger than 32 bits for the note index, as long as the first 32 bits matched the correct index. Since they can generate many unique numbers that have the same first 32 bits, a different nullifier will be created for each number. This allows them to spend the same note commitment multiple times.

The Fix

A bit length check was needed on the given note commitment index to enforce that it was at max 32 bits.

Related Vulnerabilities

Under-Constrained Circuits vulnerability Nondeterministic Circuits vulnerability

Mismatching Bit Lengths

References

Aztec Bug Disclosure

https://github.com/0xPARC/zk-bug-tracker#aztec-1