DeliveryPlace::settleAskTaker function checks the wrong address which will cause three things:
Bid Maker offer will be able to settle his own offer
Ask Taker will not be able to settle.
Possible loss of funds.
The specific line of code is here
Easiest way to explain is with an example PoC and please read the description after the PoC to explain the steps:
Paste the following test into PreMarkets.t.sol and run with forge test --mt test_settle_ask_taker_wrong_address_check -vvv
In the PoC above user calls createOffer and opens a bid offer which is a buy offer for 1000 points and user is a maker
Next, user1 calls createTaker and becomes a taker promising to sell user 500 points.
Next updateMarket is called and the market status moves to settling
The following part is where the error occurs:
Next user calls settleAskTaker which does not revert, but it should.
user transfers pointTokens to the contract to settle their own bid
If implemented correctly the code process should be:
4. user1 calls the settleAskTaker
5. user1 transfers pointTokens to the contract to settle their createOffer which was a promise to sell 500 points.
Protocol will not function correctly, orders will not be settled, and will cause a loss of funds for users.
In the above PoC example user will lose their deposit for the initial createOffer and the actual taker user1 will not be able to settle.
Foundry and manual review
Makes the following changes here in the DeliveryPlace::settleAskTaker function.
Valid high severity, when taker offers are created pointing to a `offer`, the relevant `stockInfoMap` offers are created with the owner of the offer aka `authority`, set as the creater of the offer, as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L245). Because of the wrong check within settleAskTaker, it will permanently DoS the final settlement functionality for taker offers for the maker that listed the original offer, essentially bricking the whole functionality of the market i.e. maker will always get refunded the original collateral, and takers will never be able to transact the original points put up by the maker. This occurs regardless of market mode.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.