RentPayload ’s signature can be replayed
The RentPayload signature lacked a unique identifier, so a signature could be replayed across multiple PAY orders with identical metadata. An attacker could reuse their own valid signature to fulfil other lenders' orders and collect the rental earnings.
Submitted by 0xpiken, also found by hals, trachev, hash, rbserver, evmboi32, bareli, OMEN, Kalyan-Singh, Topmark, kaden, and peter
A malicious user could potentially fulfill all PAY orders that own the same value of zonehash.
Proof of Concept
The rental process in reNFT can simply be described as follows:
-
lendercreate eitherBASEorPAYorder, which includes azoneHash. -
renterfulfills the rental order by providing certain items, includingfulfiller,payload(a structured data ofRentPayload), and its corresponding signature. -
Once the rental order is created,
Create#validateOrder()will be executed to verify if the rental order is valid:- decode
payloadand itssignaturefromzoneParams.extraData - Check if the signature is expired by comparing
payload.expirationandblock.timestamp - Recover the signer from
payloadand itssignatureand check if the signer is protocol signer - check if
zonehashis equal to the derived hash ofpayload.metadata
- decode
Let’s take a look at RentPayload and its referenced structures:
struct RentPayload {
OrderFulfillment fulfillment;
OrderMetadata metadata;
uint256 expiration;
address intendedFulfiller;
}
struct OrderFulfillment {
// Rental wallet address.
address recipient;
}
struct OrderMetadata {
// Type of order being created.
OrderType orderType;
// Duration of the rental in seconds.
uint256 rentDuration;
// Hooks that will act as middleware for the items in the order.
Hook[] hooks;
// Any extra data to be emitted upon order fulfillment.
bytes emittedExtraData;
}
By observing all items in Rentpayload, it’s obvious that there is no way to verify whether the signature of a payload has been used or not. The signature verification can always be passed as long as it has not expired.
If multiple PAY rental orders own the same metadata, a user could potentially utilize their payload and unexpired signature to fulfill all these rental orders and acquire rental earnings. Since OrderMetadata structure is very simple, the chance that two different orders own same metadata could be high.
Update testcase test_stopRentBatch_payOrders_allDifferentLenders()in StopRentBatch.t.sol with below codes and run forge test --match-test test_stopRentBatch_payOrders_allDifferentLenders:
function test_stopRentBatch_payOrders_allDifferentLenders() public {
// create an array of offerers
ProtocolAccount[] memory offerers = new ProtocolAccount[](3);
offerers[0] = alice;
offerers[1] = bob;
offerers[2] = carol;
// for each offerer, create an order and a fulfillment
for (uint256 i = 0; i < offerers.length; i++) {
// create a PAY order
createOrder({
offerer: offerers[i],
orderType: OrderType.PAY,
erc721Offers: 1,
erc1155Offers: 0,
erc20Offers: 1,
erc721Considerations: 0,
erc1155Considerations: 0,
erc20Considerations: 0
});
// finalize the pay order creation
(
Order memory payOrder,
bytes32 payOrderHash,
OrderMetadata memory payOrderMetadata
) = finalizeOrder();
// create a PAYEE order. The fulfiller will be the offerer.
createOrder({
offerer: dan,
orderType: OrderType.PAYEE,
erc721Offers: 0,
erc1155Offers: 0,
erc20Offers: 0,
erc721Considerations: 1,
erc1155Considerations: 0,
erc20Considerations: 1
});
// finalize the pay order creation
(
Order memory payeeOrder,
bytes32 payeeOrderHash,
OrderMetadata memory payeeOrderMetadata
) = finalizeOrder();
// create an order fulfillment for the pay order
createOrderFulfillment({
_fulfiller: dan,
order: payOrder,
orderHash: payOrderHash,
metadata: payOrderMetadata
});
// create an order fulfillment for the payee order
createOrderFulfillment({
_fulfiller: dan,
order: payeeOrder,
orderHash: payeeOrderHash,
metadata: payeeOrderMetadata
});
+ console.logBytes(ordersToFulfill[i*2].advancedOrder.extraData);
// add an amendment to include the seaport fulfillment structs
withLinkedPayAndPayeeOrders({
payOrderIndex: (i * 2),
payeeOrderIndex: (i * 2) + 1
});
}
// finalize the order pay/payee order fulfillments
RentalOrder[] memory rentalOrders = finalizePayOrdersFulfillment();
// pull out just the PAY orders
RentalOrder[] memory payRentalOrders = new RentalOrder[](3);
for (uint256 i = 0; i < rentalOrders.length; i++) {
if (rentalOrders[i].orderType == OrderType.PAY) {
payRentalOrders[i / 2] = rentalOrders[i];
}
}
// speed up in time past the rental expiration
vm.warp(block.timestamp + 750);
// renter stops the rental order
vm.prank(dan.addr);
stop.stopRentBatch(payRentalOrders);
// for each rental order stopped, perform some assertions
for (uint256 i = 0; i < payRentalOrders.length; i++) {
// assert that the rental order doesnt exist in storage
assertEq(STORE.orders(payRentalOrders[i].seaportOrderHash), false);
// assert that the token is no longer rented out in storage
assertEq(
STORE.isRentedOut(
payRentalOrders[i].rentalWallet,
address(erc721s[0]),
i
),
false
);
// assert that the ERC721 is back to its original owner
assertEq(erc721s[0].ownerOf(i), address(offerers[i].addr));
// assert that each offerer made a payment
assertEq(erc20s[0].balanceOf(offerers[i].addr), uint256(9900));
}
// assert that the payments were pulled from the escrow contract
assertEq(erc20s[0].balanceOf(address(ESCRW)), uint256(0));
// assert that the fulfiller was paid for each order
assertEq(erc20s[0].balanceOf(dan.addr), uint256(10300));
}
You may find out that all extraData are same although the rental orders are created by different lenders.
Recommended Mitigation Steps
Introduces a field into RentPayload to ensure every payload unique. It is feasible using orderHash of the rental order:
struct RentPayload {
bytes32 orderHash;
OrderFulfillment fulfillment;
OrderMetadata metadata;
uint256 expiration;
address intendedFulfiller;
}
0xean (Judge) decreased severity to Medium
Alec1017 (reNFT) confirmed via duplicate #239
The PR here - Prevents
RentPayloadreplayability and ensures that orders must be unique by disallowing partial orders from seaport.
Status: Mitigation confirmed. Full details in reports from juancito, EV_om and sin1st3r__.
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
Likely the RentPayload structure has no field that uniquely ties a signature to a specific order, so identical metadata produces identical payloads and signatures remain valid for any matching order.
Impact
A malicious user could fulfil multiple PAY orders that share the same metadata and acquire the rental earnings for each, though the judge reduced severity to Medium.
What the attacker needed
Multiple PAY orders with identical metadata; attacker has a valid unexpired signature
The fix
The issue was mitigated by adding an orderHash field to RentPayload to make each payload unique and by disallowing partial orders from Seaport.
How it was found
- Create multiple PAY orders from different lenders that share the same metadata.
- Finalise each order and observe that the extraData (payload and signature) is identical across them.
- Use one unexpired payload and signature to fulfil all the matching PAY orders.
- Collect the rental earnings for each fulfilled order.
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 is like a stamped approval that proves a request came from the right person. Here, the approval did not include anything that made it unique to one order, so the same stamp could be copied onto other orders that looked identical. That let someone collect payments for rentals they did not actually set up.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.