OptimisticListingSeaport.propose sets pendingBalances of newly added proposer instead of previous one
In the propose function, the contract updates the pending balance of the new proposer instead of the previous one, so the old proposer loses their collateral and the new proposer can make proposals without paying.
Submitted by Lambda, also found by Trust
In OptimisticListingSeaport.propose, pendingBalances is set to the collateral. The purpose of this is that the proposer of a previous proposal can withdraw his collateral afterwards. However, this is done on the storage variable proposedListing after the new listing is already set:
_setListing(proposedListing, msg.sender, _collateral, _pricePerToken, block.timestamp);
// Sets collateral amount to pending balances for withdrawal
pendingBalances[_vault][proposedListing.proposer] += proposedListing.collateral;
Because of that, it will actually set pendingBalances of the new proposer. Therefore, the old proposer loses his collateral and the new one can make proposals for free.
Proof Of Concept
--- a/test/seaport/OptimisticListingSeaport.t.sol
+++ b/test/seaport/OptimisticListingSeaport.t.sol
@@ -379,8 +379,11 @@ contract OptimisticListingSeaportTest is SeaportTestUtil {
/// ===== LIST =====
/// ================
function testList(uint256 _collateral, uint256 _price) public {
// setup
testPropose(_collateral, _price);
+ assertEq(optimistic.pendingBalances(vault, bob), 0);
_increaseTime(PROPOSAL_PERIOD);
_collateral = _boundCollateral(_collateral, bobTokenBalance);
_price = _boundPrice(_price);
This test fails and optimistic.pendingBalances(vault, bob) is equal to _collateral.
Recommended Mitigation Steps
Run pendingBalances[_vault][proposedListing.proposer] += proposedListing.collateral; before the _setListing call, in which case the above PoC no longer works.
Because of that, it will actually set pendingBalances of the new proposer. Therefore, the old proposer loses his collateral and the new one can make proposals for free.
Seems like intended behaviour to me (actually set pendingBalances of the new proposer). The old proposer wouldn’t be losing his collateral because his pendingBalances would’ve been set when he called
propose().
mehtaculous (Tessera) confirmed and commented:
Agree with severity. The suggested solution makes sense.
stevennevins (Tessera) mitigated:
https://github.com/fractional-company/modular-fractional/pull/202
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
The code updates pendingBalances using proposedListing.proposer after _setListing has already changed proposedListing.proposer to the new proposer, so the old proposer's collateral is credited to the new one.
Impact
The previous proposer loses their collateral and the new proposer can make proposals for free.
What the attacker needed
A proposal already exists; attacker can call propose
The fix
The pendingBalances update should be moved before the _setListing call, and the text says this was mitigated.
How it was found
- Call propose with some collateral and price.
- Check that pendingBalances for the previous proposer is zero.
- Observe that pendingBalances for the new proposer equals the collateral.
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 smart contract lets people propose listings by putting up collateral (a deposit). When a new proposal is made, the contract should record that the previous proposer can take their deposit back. Instead, it records the deposit for the new proposer, so the old proposer's money is stuck and the new proposer gets a free deposit.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.