When a Maker creates an ASK Offer, they are offering to sell their points at a specified price. Conversely, a Taker might place a BID Order to purchase those points. In this scenario, when the Token Generation Event (TGE) occurs, the Maker is responsible for settling the transaction and providing the tokens. Similarly, the Taker must finalize their bid after the Maker has settled. Once the bid is closed, the Taker should be able to withdraw the points they have acquired. However, due to incorrect accounting logic in the current protocol implementation, Takers are unable to withdraw the points as expected.
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L187
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L109
The issue stems from the closeBidTaker() function within the DeliveryPlace contract. Specifically, on line #187, the address of the collateral token is mistakenly used instead of the address of the points token. In this scenario, the correct approach should be to account for the number of points tokens being purchased by the Taker, ensuring accurate tracking.
The following test case can be added to the existing test file:
NOTE: need to add the following line: import {MarketPlaceStatus} from "../src/interfaces/ISystemConfig.sol";
Consequently, Takers are unable to withdraw their points tokens. More critically, the flaw allows users to withdraw collateral tokens instead of the intended points tokens, posing a severe risk to the protocol. This vulnerability could lead to substantial financial losses and significantly disrupt the marketplace's overall functionality.
Manual review, Foundry.
Instead of using makerInfo.tokenAddress which is the collateral token address, use the address of the points token.
Valid high severity, In `settleAskTaker/closeBidTaker`, by assigning collateral token to user balance instead of point token, if collateral token is worth more than point, this can cause stealing of other users collateral tokens within the CapitalPool contract, If the opposite occurs, user loses funds based on the points they are supposed to receive
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.