Open c4-bot-9 opened 10 months ago
141345 marked the issue as duplicate of #139
0xean marked the issue as satisfactory
Hi @0xean, could you consider selecting this issue for the report instead of #139? I believe it would be a better choice for the report due to the following reasons:
I would argue that especially the POC is of considerable value here, since this is an issue with many moving parts and it is hard to fully trust an analysis based just on code review to verify its validity.
Thanks for your consideration!
0xean marked the issue as selected for report
Alec1017 (sponsor) confirmed
Lines of code
https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Create.sol#L733
Vulnerability details
Impact
The
Create
contract is responsible for creating a rental. It achieves this by acting as a SeaportZone
, and storing and validating orders as rentals when they are fulfilled on Seaport.However, one thing it doesn't account for is the fact that Seaport allows for "tipping" in the form of ERC20 tokens as part of the order fulfillment process. This is done by extending the
consideration
array in the order with additional ERC20 tokens.From the Seaport docs (emphasis mine):
This other passage, while discussing a different issue, even highlights the root cause of this vulnerability (the zone does not properly allocate consideration extensions):
Let's dive in and see how tipping works exactly. We know fulfillers may use the entry points listed here, the first of which is simply a wrapper to
_validateAndFulfillAdvancedOrder()
. This function calls_validateOrderAndUpdateStatus()
, which derives the order hash by calling_assertConsiderationLengthAndGetOrderHash()
. At the end of the trail, we can see that the order hash is finally derived in_deriveOrderHash()
from other order parameters as well as the consideration array, but only up to thetotalOriginalConsiderationItems
value in theparameters
of theAdvancedOrder
passed by the fulfiller as argument. This value reflects the original length of the consideration items in the order. https://github.com/ProjectOpenSea/seaport-types/blob/25bae8ddfa8709e5c51ab429fe06024e46a18f15/src/lib/ConsiderationStructs.sol#L143-L156Thus we can see that when deriving the order hash the extra consideration items are ignored, which is what allows the original signature of the offerer to match. However, in the
ZoneParameters
passed on to the zone, all consideration items are included in one array, and there is no obvious way to distinguish tips from original items:Finally, while the
validateOrder()
function in theCreate
contract verifies that the order fulfillment has been signed by the reNFT signer, the signedRentPayload
does not depend on the consideration items, hence tipping is still possible.The vulnerability arises when this capability is exploited to add a malicious ERC20 token to the
consideration
array. This malicious token can be designed to revert on transfer, causing the rental stop process to fail. As a result, the rented assets remain locked in the rental safe indefinitely.Proof of Concept
We can validate the vulnerability through an additional test case for the
Rent.t.sol
test file. This test case will simulate the exploit scenario and confirm the issue by performing the following actions:BASE
order with Alice as the offerer.consideration
array of the order.A simple exploit contract could look as follows:
And the test:
To run the exploit test:
test/mocks/tokens/weird/MockRevertOnTransferERC20.sol
.Rent.t.sol
test file and run it using the commandforge test --mt test_Vuln_OrderHijackingByTippingMaliciousERC20
. This will run the test above, which should demonstrate the exploit by successfully appending a malicious ERC20 to an existing order and starting a rental that cannot be stopped.Tools Used
Manual review, Foundry
Recommended Mitigation Steps
Disallow tipping, either by removing this functionality in the Seaport fork or, if this isn't possible, perhaps by adding the size of the consideration items to the
ZoneParameters
and reverting if there are more. This would prevent the addition of malicious ERC20 tokens to theconsideration
array, thereby preventing the hijacking of orders and the indefinite locking of rented assets in the rental safe.Assessed type
call/delegatecall