Anyone can cancel other accounts `nonces` and `groups`, leading to griefing their `Intents`
The verifier contracts only check that a signature is valid for the signer address, but do not verify that the signer is authorised for the account whose nonce or group is being cancelled. An attacker can therefore cancel any user's pending intents or groups by submitting a valid signature from any address.
Source: https://github.com/sherlock-audit/2024-08-perennial-v2-update-3-judging/issues/54
Found by
Albort, Tendency, bin2chen, eeyore
Summary
Within the AccountVerifier, OrderVerifier, and Verifier, anyone can call the verifyCommon() or cancelGroupWithSignature() functions with properly crafted data and signatures to cancel other users nonces or groups. This occurs because the signature is only compared to ensure the signer is the address from common.signer, but the cancellation is performed for common.account. There is no additional validation to confirm that common.signer is an allowed signer for the common.account.
Vulnerability Detail
As seen in the VerifierBase, the only check performed is signature validation against common.signer:
function verifyCommon(Common calldata common, bytes calldata signature)
external
validateAndCancel(common, signature)
{
@> if (!SignatureChecker.isValidSignatureNow(common.signer, _hashTypedDataV4(CommonLib.hash(common)), signature))
revert VerifierInvalidSignerError();
}
In the validateAndCancel() modifier, the nonce is prechecked and later canceled for common.account without verifying that common.signer is an allowed signer for common.account:
modifier validateAndCancel(Common calldata common, bytes calldata signature) {
if (common.domain != msg.sender) revert VerifierInvalidDomainError();
if (signature.length != 65) revert VerifierInvalidSignatureError();
if (nonces[common.account][common.nonce]) revert VerifierInvalidNonceError();
if (groups[common.account][common.group]) revert VerifierInvalidGroupError();
if (block.timestamp >= common.expiry) revert VerifierInvalidExpiryError();
@> _cancelNonce(common.account, common.nonce);
_;
}
As the same validation flow is used in cancelGroupWithSignature(), any group can be canceled as well.
This can lead to situations where:
- Any pending
Intentcan be canceled by anyone, rendering theIntentsuseless. - Market makers could cancel each other's orders or market fill orders to lower competitors fill rates and ban them from the Solver API.
- All pending limit orders could be canceled by other users, breaking the limit order
Intentssystem.
The VerifierBase is used in all verifier contracts, affecting all functions that rely on Intents.
Impact
- Missing validation.
Intentsfunctionality broken.
Code Snippet
https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/root/contracts/verifier/VerifierBase.sol#L18-L24
https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/root/contracts/verifier/VerifierBase.sol#L54-L57
https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/root/contracts/verifier/VerifierBase.sol#L76-L86
Tool used
Manual Review
Recommendation
Add additional validation to ensure that common.signer is an allowed signer for common.account.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/equilibria-xyz/perennial-v2/pull/444 https://github.com/equilibria-xyz/root/pull/104
arjun-io
Note that in addition to the above PR, there is a 1-line update to the root package to enable this fix: https://github.com/equilibria-xyz/root/pull/104
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code validates the signature against `common.signer` but fails to verify that `common.signer` is an authorised signer for `common.account` before cancelling the nonce or group.
Impact
Any pending intent or group can be cancelled by anyone, potentially rendering the intents system useless and allowing market makers to grief competitors.
What the attacker needed
None
The fix
The protocol team fixed this issue by adding validation to ensure that `common.signer` is an allowed signer for `common.account`.
How it was found
- Craft a `Common` struct with the victim's account and a nonce or group to cancel.
- Sign the struct with any private key, setting `common.signer` to the corresponding address.
- Call `verifyCommon()` or `cancelGroupWithSignature()` with the crafted data and signature.
- The contract validates the signature against `common.signer` and cancels the nonce or group for `common.account`.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A signature proves that someone approved a message, but the system must also check that this someone is allowed to act for the account being affected. Here, the check was missing, so anyone could cancel other people's pending orders by providing a signature from their own address.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.