When a market maker lists their offer in protected mode, they must provide the collateral rate at which the assets will be sold and also deposit the collateral accordingly. However, if the market maker closes their listing, they might exploit the protocol by withdrawing more funds ten their deposits due to an incorrect collateral rate used in the deposit calculation.
The Tadle allows makers to list points for sale that they have either purchased from the initial market maker or that they themselves initially provided. Offers can be listed in either Protected or Turbo mode.
In Protected mode, the listOffer
function lists the offer with a new collateral rate and stores the deposited cryptocurrency for post-settlement. This deposit will be transferred to the buyer after the trade is completed.
The issue here is that makers are allowed to set a new collateral rate when listing an offer. However, the system uses the original offer's collateral rate to calculate the deposit amount.
@1
uses the collateral rate from the original offer to determine the collateral deposit amount, while @2
stores the collateral rate specified by the market maker for the current offer.
In the offer closure process, we use the collateral rate specified by the market maker at the time of listing the offer.
This can lead to asset loss for Tadle in the following scenario:
Bob purchases 100 points from Alice at a collateral rate of 12,000. The collateral rate for the original offer is 12,000.
Bob lists the 100 points with a new collateral rate of 13,000, resulting in a deposit amount of 1,200,000. Here we use the collateral rate from origin offer.
At this point, Bob has deposited 1,200,000 collateral tokens, and the collateral rate for his offer is 13,000.
When Bob calls closeOffer
, the offer is closed and the refund amount is stored in Bob's balance mapping.Here we use the collateral rate of given offer , Due to the incorrect collateral rate used for calculation, the refund amount stored user balance mapping is 1,300,000.
In summary, when deducting the deposit amount from the maker, the collateral rate of the original offer is used. However, when closing the same offer, the collateral rate of the current offer is used. This discrepancy allows the market maker to exploit the protocol and steal funds.
The following coded POC proof that the maker will have more funds then his initial funds :
Add following test case to PreMarket.t.sol
:
Run with command : forge test --mt test_list_and_close_offer_hack -vvv
The discrepancy between using different collateral rate in case of listOffer
and closeOffer
will allow attacker to steal funds from The Tadle Protocol.
Foundry
One Potential Fix would be Use the new collateral rate to calculate the deposit amount in Protected mode, as the maker will be depositing the collateral.
Valid high severity, because the collateral rate utilized when creating an offer is stale and retrieved from a previously set collateral rate, it allows possible manipilation of refund amounts using an inflated collateral rate to drain funds from the CapitalPool contract
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.