When a user wants to purchase points in a specific marketplace at a price they are willing to pay, they can create a BID Offer. Conversely, users who are ready to sell their points at that price can place an ASK Order. Once the Token Generation Event (TGE) occurs, sellers are responsible for fulfilling the deal by transferring the points to the buyer. Sellers are incentivized to complete the transaction because they have posted collateral when they created the ASK Order, ensuring their commitment.
In code terms, Takers must transfer the points tokens via the settleAskTaker() function in DeliveryPlace.sol. The transfer process isn't direct—Takers transfer the tokens to the protocol, and the virtual balance of the Maker is updated in TokenManager.sol. However, there is an issue: the settleAskTaker() function currently does not account correctly when Takers settle, leading to potential discrepancies in the Maker's balance and affecting the overall transaction integrity.
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/DeliveryPlace.sol#L384
https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/PreMarkets.sol#L109
On line #384 in DeliveryPlace.sol the wrong token address is updated. As we are updating the balance for the PointToken we must provide the corresponding address.
makerInfo.tokenAddress is the address of the collateral token which is set initially when Offer is created by a Maker in createOffer() in PreMarkets.sol on line #109.
Using the protocol test file, I have added another test case which shows the described issue.
NOTE: need to add the following line: import {MarketPlaceStatus} from "../src/interfaces/ISystemConfig.sol";
The incorrect accounting in the settleAskTaker() function poses a significant risk to the protocol. Users could potentially exploit this vulnerability to withdraw collateral tokens instead of the intended point tokens. This could lead to severe financial losses for the protocol, as collateral meant to secure transactions could be drained improperly. Moreover, the integrity of the marketplace would be compromised.
Manual review, Foundry.
Instead of makerInfo.tokenAddress which is the address of the collateral token, user marketPlaceInfo.tokenAddress which is the address of the point 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.