According to the EIP-712 specification, structs are encoded by taking the hash of the concatenation of their type hash and the encoding of each of their fields. However, the _deriveOrderMetadataHash() function in the Signer contract is incorrect in that it omits one of the struct's fields, emittedExtraData, when computing the hash of the OrderMetadata struct.
The emittedExtraData field is left out when computing the hash of the OrderMetadata. This breaks EIP-712 compliance, so can be seen as an instance of “function of the protocol or its availability could be impacted” and is hence classified as medium severity.
Tools Used
Manual review
Recommended Mitigation Steps
To mitigate this issue, the _deriveOrderMetadataHash() function should be updated to include the emittedExtraData field when computing the hash of the OrderMetadata struct. This will ensure that the function is in compliance with the EIP-712 specification and that the hash accurately represents the OrderMetadata struct.
Lines of code
https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/packages/Signer.sol#L231-L238
Vulnerability details
Impact
According to the EIP-712 specification, structs are encoded by taking the hash of the concatenation of their type hash and the encoding of each of their fields. However, the
_deriveOrderMetadataHash()
function in theSigner
contract is incorrect in that it omits one of the struct's fields,emittedExtraData
, when computing the hash of theOrderMetadata
struct.Proof of Concept
The
OrderMetadata
struct is defined as follows:But the
_deriveOrderMetadataHash()
returns: https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/packages/Signer.sol#L232-L238The
emittedExtraData
field is left out when computing the hash of theOrderMetadata
. This breaks EIP-712 compliance, so can be seen as an instance of “function of the protocol or its availability could be impacted” and is hence classified as medium severity.Tools Used
Manual review
Recommended Mitigation Steps
To mitigate this issue, the
_deriveOrderMetadataHash()
function should be updated to include theemittedExtraData
field when computing the hash of theOrderMetadata
struct. This will ensure that the function is in compliance with the EIP-712 specification and that the hash accurately represents theOrderMetadata
struct.Assessed type
Other