Platform: Code4rena
Start Date: 12/04/2023
Pot Size: $60,500 USDC
Total HM: 21
Participants: 199
Period: 7 days
Judge: hansfriese
Total Solo HM: 5
Id: 231
League: ETH
Rank: 5/199
Findings: 2
Award: $2,537.21
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: carrotsmuggler
Also found by: Ace-30, KIntern_NA, Nyx, bin2chen, cccz, juancito, mahdikarimi, mov, nobody2018
201.1223 USDC - $201.12
https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/Position.sol#L159-L167 https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/MintingHub.sol#L140-L148 https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/MintingHub.sol#L208-L214 https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/Position.sol#L307-L313
attacker buys challenge size with a low price
Let's say there is a position with 10 collateral and 100 minted zchf , both liqPrice of position and market price of collateral are 10 which means position is fully collateralized . 1 - attacker ( position owner ) changes liqPrice to 15 that allows him to mint zchf 1 day later so the position will be challenged by a challenger . 2 - a challenger performs a transaction to launche a challenge with size of 10 and since the liqPrice in position is 15 expects that a auction happens on collateral and sell in a fair price ( since we know no one would buy an asset that worth 10 zchf for 15 zchf ). 3 - attacker ( position owner ) immediately front-runs challenger and perform some stuff in one transaction , puts enough collateral in position to over-collateralize position and adjust liqPrice to a price lower than market price like 5 in this case ( more collateral he/she puts enables him to adjust lower price ) then bid on challenge with price of for example 6 ( a _bidAmountZCHF that enables buying every coll for 6 zchf ) which allows attacker to buy challenger size for 6 zchf whci is lower than market price and lower than challenger expected and avert the challenge 4- Now the attacker has a over-collateralized position and can mint new tokens or withdraw some collateral and has a health position . This attack let's the position owner buy challenge amount with low price . This doesn't effect position the attacker actually victims the challengers .
Manual Review
you can take a minPrice parameter in launch challenge function and ensure that the collateral won't be sold lower than challenger expected .
#0 - c4-pre-sort
2023-04-26T13:50:34Z
0xA5DF marked the issue as duplicate of #945
#1 - c4-judge
2023-05-18T14:50:21Z
hansfriese marked the issue as satisfactory
🌟 Selected for report: cccz
Also found by: mahdikarimi
2336.0926 USDC - $2,336.09
https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/Position.sol#L160-L162 https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/MintingHub.sol#L199-L229 https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/MintingHub.sol#L252-L276 https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/Position.sol#L349-L353
Attacker bypasses challenge and mints under-collateralized ZCHF
1 - attacker (position owner) repays all minted zchf ( minted = 0 ) withdraws amount of collateral equal or higher than minCollateral to prevent closing position in this case consider 10 collateral remained .
2 - owner adjusts price to a very high price in this case 1000 ( while market price is 10 ) and this will lead to challenge the position .
3 - challenger challenges the position ( since the price is very high on position, challenge won't be averted ) .
4 - auction starts and owner(attacker) bids a large amount in auction that no one would offer (actually owner bids on his own collateral so he can bid as much as he can without worrying about loss and win the bid ).
5 - before auction end ( end function in minting hub ) owner (attacker) puts collateral in position as much as challenge size to prevent expiring position ( since already there is minCollateral in position )
5 - As we see in the following line of code no zchf will be repaid ( since there is no minted amount ) so owner will get all bid - challenger reward
uint256 repayment = minted < volumeZCHF ? minted : volumeZCHF; // how much must be burned to make things even
6 - owner(attacker) wins the bid by just paying challenger reward , the minted is 0 , the price (liqPrice) in position is 1000 ( 990 larger than market price),there is 10 collateral in position , challenge is completed ( bypassed challenged ) and cooldown period has been passed ( since adjusting price enables 3 day cooldown ) , now he's able to mint 1000 zchf for every collateral before someone challenges the position (max : mintLimit ) .
If attacker (owner) has more capital he can bypass larger size and more challenges .
Manual Review
Consider restrict minting for at least one day after notifyChallengeSucceeded has been called successfully
#0 - c4-pre-sort
2023-04-28T15:18:21Z
0xA5DF marked the issue as duplicate of #691
#1 - c4-judge
2023-05-18T16:08:11Z
hansfriese marked the issue as satisfactory