Open c4-bot-6 opened 9 months ago
141345 marked the issue as primary issue
141345 marked the issue as sufficient quality report
Alec1017 (sponsor) confirmed
0xean marked the issue as satisfactory
0xean removed the grade
0xean marked the issue as satisfactory
0xean marked the issue as selected for report
Lines of code
https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/packages/Signer.sol#L151-L151 https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/packages/Signer.sol#L373-L375 https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/packages/Signer.sol#L384-L386 https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/packages/Signer.sol#L232-L238 https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Create.sol#L636
Vulnerability details
Impact
Being not EIP712 compliant can lead to issues with integrators and possibly DOS.
Problem 1
The implementation of the hook hash (here) is done incorrectly.
hook.extraData
is of typebytes
which according to EIP712 it is referred to as adynamic type
. Dynamic types must be first hashed withkeccak256
to become one 32-byte word before being encoded and hashed together with the typeHash and the other values.Mitigation to Problem 1:
Problem 2
Some TypeHashes are computed by using
abi.encode
instead ofabi.encodePacked
(here) which makes the typeHash value and the whole final hash different from the hash that correctly implementing EIP712 entities would get.The problem with this is that abi.encode-ing strings results in bytes with arbitrary length. In such cases (like the one here) there is a high chance that the bytes will not represent an exact N words in length (X * 32 bytes length) and the data is padded to conform uniformly to 32-byte words. This padding results in an incorrect hash of the typeHash and it will make the digest hash invalid when compared with properly implemented hashes from widely used libraries such as ethers.
Proof of Concept
Place the following code in any of the tests and run
forge test -—mt test_EIP712_encoding
This test shows that the
rentalOrderTypeHashCorrect
is the correct typeHash.Mitigation to Problem 2
Problem 3
_deriveOrderMetadataHash
constructs the hash incorrectly because _ORDER_METADATA_TYPEHASH includesuint8 orderType
andbytes emittedExtraData
(it can be seen here) but these values are not provided below the typeHash (it can be seen here).This hash is important because it is compared to the zoneHash inside
Create.sol:validateOrder → _rentFromZone → _isValidOrderMetadata
(link): So if the provided zoneHash from Seaport was generated correctly and it is not the same as the one generated by reNFT, the protocol will not be able to create any rentalOrders resulting in DOS.In any case, this implementation is not according to EIP712 and either the fields must be included or the
_ORDER_METADATA_TYPEHASH
must removeuint8 orderType
andbytes emittedExtraData
Tools Used
Manual review and Foundry for testing
Recommendations
Apply the described fixes for each example
Assessed type
Other