Fantastic Wintergreen Tapir
Medium
According to the official EIP-712 specification (Link), arrays are classified as reference types. Unlike primitive types, their encoding involves a unique process. Specifically, the specification states:
Array values are encoded as the keccak256 hash of the concatenated
encodeData
of their elements (i.e., encodingSomeType[5]
is identical to encoding a struct with fiveSomeType
members).
Link
This emphasizes that arrays should be encoded as the keccak256
hash of their concatenated encoded elements. However, in the VVVVCTokenDistributor::_isSignatureValid(...)
function, arrays are directly encoded, as seen below:
function _isSignatureValid(ClaimParams memory _params) private view returns (bool) {
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR,
keccak256(
abi.encode(
CLAIM_TYPEHASH,
_params.kycAddress,
_params.projectTokenAddress,
@> _params.projectTokenProxyWallets, // Incorrect encoding
@> _params.tokenAmountsToClaim, // Incorrect encoding
_params.nonce,
_params.deadline
)
)
)
);
address recoveredAddress = ECDSA.recover(digest, _params.signature);
bool isSigner = recoveredAddress == signer;
bool isExpired = block.timestamp > _params.deadline;
return isSigner && !isExpired;
}
GitHub: Link
This implementation conflicts with the EIP-712 specification and could cause signature verification failures.
Incorrect encoding of array elements when generating the digest.
No response
No response
No response
Signature verification may fail, leading to potential denial-of-service (DoS) scenarios where valid claims are rejected.
The following resources illustrate the issue:
- https://mirror.xyz/jaredborders.eth/G2RP5XAfLbNZv01DXgxuzv_34bQF_PuO1X2u0Nhop9g
- https://ethereum.stackexchange.com/questions/125105/signing-an-array-whit-eth-signtypeddata-v4
The resources linked in the PoC section provide guidance on correctly encoding arrays in accordance with EIP-712 standards.
Here is an example from seaport contracts: https://github.com/ProjectOpenSea/seaport/blob/a62c2f8f484784735025d7b03ccb37865bc39e5a/reference/lib/ReferenceGettersAndDerivers.sol#L130