Platform: Code4rena
Start Date: 03/05/2022
Pot Size: $50,000 USDC
Total HM: 4
Participants: 46
Period: 5 days
Judge: gzeon
Total Solo HM: 2
Id: 117
League: ETH
Rank: 1/46
Findings: 3
Award: $17,568.24
π Selected for report: 1
π Solo Findings: 1
π Selected for report: BowTiedWardens
Also found by: leastwood, sorrynotsorry
The .transfer()
function intends to transfer an ETH amount with a fixed amount of 2300
gas. This function is not equipped to handle changes in the underlying .send()
and .transfer()
functions which may supply different amounts of gas in the future. Additionally, if the recipient implements a fallback function containing some sort of logic, this may inevitably revert, meaning the original supplier cannot redeem their cTokens
.
Consider using .call()
instead with the checks-effects-interactions pattern implemented correctly. Careful consideration needs to be made to prevent reentrancy.
#0 - bunkerfinance-dev
2022-05-18T06:35:11Z
Duplicate of #116
π Selected for report: leastwood
13743.2396 USDC - $13,743.24
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L240-L242 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L260-L262 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L469-L472 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L496-L499 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L1139-L1155 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L1222-L1243
The updateCompSupplyIndex()
and distributeSupplierComp()
functions are used by Compound to track distributions owed to users for supplying funds to the protocol. Bunker protocol is a fork of compound with NFT integration, however, part of the original functionality appears to have been mistakenly commented out. As a result, whenever users enter or exit the protocol, COMP
distributions will not be correctly calculated for suppliers. At first glance, its possible that this was intended, however, there is nothing stated in the docs that seems to indicate such. Additionally, the COMP
distribution functionality has not been commented out for borrowers. Therefore, tokens will still be distributed for borrowers.
Both the updateCompSupplyIndex()
and updateCompBorrowIndex()
functions operate on the same compSpeeds
value which dictates how many tokens are distributed on each block. Therefore, you cannot directly disable the functionality of supplier distributions without altering how distributions are calculated for borrowers. Because of this, suppliers can manipulate their yield by supplying tokens, calling updateCompSupplyIndex()
and distributeSupplierComp()
, removing their tokens and repeating the same process on other accounts. This completely breaks all yield distributions and there is currently no way to upgrade the contracts to alter the contract's behaviour. Tokens can be claimed by redepositing in a previously "checkpointed" account, calling claimComp()
and removing tokens before re-supplying on another account.
Consider commenting all behaviour associated with token distributions if token distributions are not meant to be supported. Otherwise, it is worthwhile uncommenting all occurrences of the updateCompSupplyIndex()
and distributeSupplierComp()
functions.
#0 - bunkerfinance-dev
2022-05-18T06:34:44Z
We are not going to use the COMP code. We could fix documentation or comment more code to make this clearer though.
#1 - gzeoneth
2022-05-29T11:49:06Z
Comptroller.sol is in scope of this contest, and there are no indication that token distribution will be disabled despite the sponsor claim they are not going to use the $COMP code. However, it is also true the deployment setup within contest repo lack the deployment of $COMP and its distribution. I believe this is a valid Med Risk issue given fund(reward token) can be lost in certain assumptions.
π Selected for report: BowTiedWardens
Also found by: 0x1337, 0x1f8b, 0x4non, 0xDjango, David_, Funen, GimelSec, IllIllI, Picodes, TerrierLover, WatchPug, bobi, cryptphi, csanuragjain, delfin454000, dirk_y, ellahi, fatherOfBlocks, hyh, ilan, jayjonah8, kebabsec, leastwood, oyc_109, robee, samruna, simon135, sorrynotsorry, throttle
114.326 USDC - $114.33
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Oracles/UniswapV2PriceOracle.sol#L23-L48 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Oracles/UniswapV2PriceOracle.sol#L126-L144 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Oracles/UniswapV2PriceOracle.sol#L170-L178
The Uniswap oracle utilises a 30 minute TWAP window which helps to protect the protocol from flash loan manipulation. However, in order to keep this data fresh, the update()
function must be called by some individual on each 30 minute interval. Failure to do so will result in an extended TWAP window which may return a drastically different price when compared to the 30 minute TWAP window. As a result, if the Uniswap oracle is not updated for an extended period of time and a number of individuals borrow based on this information, a subsequent update may lead to a liquidation as the 30 minute TWAP price is lower than the currently referenced price.
The sponsor has stated that they will be in charge of constantly upkeeping this oracle, however, this is a centralised point of failure and there is no guarantee or incentive that this will continue in the long run. I strongly believe that protocols need to be self-sufficient and they should not be reliant on some benevolent actor.
Consider integrating some sort of incentive behaviour into the Uniswap oracle model to ensure price information is updated on each update interval. There are a couple of implementations which verify block data on-chain, ensuring past price information is valid, however, this has serious overhead gas costs due to on-chain verification. Therefore, I believe some sort of on-chain incentive mechanism is ideal in this situation.
#0 - bunkerfinance-dev
2022-05-18T06:46:35Z
We are aware of this and will eat the costs of upkeeping the oracle for now.
#1 - gzeoneth
2022-05-29T13:03:09Z
Downgrading to Low / QA.
#2 - gzeoneth
2022-05-29T13:24:17Z
Treating as warden's QA report.