Skip to content
Request an audit

‹ All findings

_checkAndIncrementNonce in ERC5805 raises a ReusedNonce error for non used nonces

Low/InfoM^0 Minter Gateway·Three Sigma · Stablecoin framework · 8th January, 2024Codebase3S-M^0-N13

Description

The ERC5805._checkAndIncrementNonce function makes sure the nonce being used in a signature is the right one.

If it is, it increments it:

solidity
function _checkAndIncrementNonce(address account_, uint256 nonce_)
internal {
    uint256 currentNonce_ = nonces[account_];
    if (nonce_ != currentNonce_) revert ReusedNonce(nonce_, currentNonce_);
    unchecked {

nonces[account_] = currentNonce_ + 1; // Nonce realistically cannot overflow.

solidity
}
}

The error being raised when nonce_ != currentNonce_ is misleading. The if statement doesn't necessarily mean that the nonce_ value being used has been used in past signatures, rather it means that it is not the expected current nonce of the account.

For example, if the current nonce is 1 and the user signs the data with nonce 3, this should revert, but nonce 3 hasn't been used yet.

Recommendation

Consider renaming the error to more accurately describe the issue. For example, NotCurrentNonce.

Status

Addressed in #d75ef4a, #4e20a80.