COMP Distributions Can Be Manipulated And Duplicated Across Any Number Of Accounts
The COMP distribution functions for suppliers were commented out, so supplier rewards are not correctly calculated, while borrower distributions remain active. An attacker could repeatedly supply and withdraw tokens across multiple accounts to manipulate and duplicate COMP distributions.
Submitted by leastwood
Comptroller.sol#L240-L242 Comptroller.sol#L260-L262 Comptroller.sol#L469-L472 Comptroller.sol#L496-L499 Comptroller.sol#L1139-L1155 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.
Recommended Mitigation Steps
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.
bunkerfinance-dev (bunker.finance) acknowledged, but disagreed with High severity and commented:
We are not going to use the COMP code. We could fix documentation or comment more code to make this clearer though.
gzeon (judge) decreased severity to Medium and commented:
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.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the supplier reward update functions were mistakenly commented out, leaving only borrower distributions active and allowing manipulation.
Impact
This could break all yield distributions and allow tokens to be claimed improperly, though the sponsor stated they do not intend to use the COMP code.
What the attacker needed
Ability to supply and withdraw tokens; multiple accounts
The fix
The sponsor acknowledged but disagreed with the severity and stated they will not use the COMP code; they suggested fixing documentation or commenting more code to clarify.
How it was found
- Supply tokens to the protocol.
- Call updateCompSupplyIndex() and distributeSupplierComp().
- Remove the supplied tokens.
- Repeat the same process on other accounts.
- Redeposit in a previously checkpointed account, call claimComp(), and remove tokens before re-supplying on another account.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a lending protocol, users earn reward tokens for supplying or borrowing funds. Here, the code that updates rewards for suppliers was disabled, but the code for borrowers still works. This lets someone game the system by moving funds between accounts to collect more rewards than they should.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.