When point tokens are distributed in closeBidTaker
and settleAskTaker
, instead of increasing the balance of marketPlaceInfo.tokenAddress
, the balance of makerInfo.tokenAddress
is increased instead:
The makerInfo.tokenAddress
is the token used for buying/selling points and for collateral (i.e. USDC or WETH). When points are distributed, by increasing this balance instead of marketPlaceInfo.tokenAddress
, the obvious bug is that users will not get their point tokens.
There is, however, another vulnerability that happens if the value of _tokenPerPoint
set in SystemConfig::updateMarket
is more than 1e18; that means that users will get more tokens than points they had. Let’s consider the following scenario:
An offer is created by a maker for 1000 points at USDC1000
A user buys 100 points for USDC100
The offer is completely sold off
Later, the offer is settled with:
o settledPoints: 1000
o tokenPerPoint: 3e18 hence,
o settledPointTokenAmount
: 3e21
This user’s TokenBalanceType.PointToken
balance is increased to 3e20
Since this balance is added as makerInfo.tokenAddress
and it is more than the initial USDC100 this user spent, he can withdraw it and get USDC300.
Add this to PreMarkets.t.sol
:
As can be seen, the attacker started with USDC1,000 and ended up with USDC1,196.5
Foundry
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.