YAxisVotePower.balanceOf can be manipulated
The YAxisVotePower.balanceOf function calculates voting power using the current reserves of a Uniswap pool, which can be temporarily manipulated. An attacker could increase their voting power to pass a governance proposal.
Submitted by cmichel
The YAxisVotePower.balanceOf contract uses the Uniswap pool reserves to compute a _lpStakingYax reward:
(uint256 _yaxReserves,,) = yaxisEthUniswapV2Pair.getReserves();
int256 _lpStakingYax = _yaxReserves
.mul(_stakeAmount)
.div(_supply)
.add(rewardsYaxisEth.earned(_voter));
The pool can be temporarily manipulated to increase the _yaxReserves amount.
Impact
If this voting power is used for governance proposals, an attacker can increase their voting power and pass a proposal.
Recommended Mitigation Steps
One could build a TWAP-style contract that tracks a time-weighted-average reserve amount (instead of the price in traditional TWAPs). This can then not be manipulated by flashloans.
I disagree with the “sponsor disputed” tag.
I think this is a valid issue and makes
balanceOf(_voter)susceptible to flashloan attacks. However, as long asbalanceOf(_voter)is always called by a trusted EOA during governance vote counts, this should not be a problem. I assume this is the case for governance proposals. If that is not the case, I would recommend changing the code. Otherwise, changing the risk to “documentation” would be reasonable.
GalloDaSballo (judge) commented:
Agree with original warden finding, as well as severity
The ability to trigger the count at any time does prevent a flashloan attack (as flashloans are atomic) It would allow the privilege of the flashloan attack to the trusted EOA (admin privilege)
Additionally the voting power can still be frontrun, while you cannot manipulate that voting power via a flashloan, you can just buy and sell your position on the same block as when the count is being taken
Due to this I will up the severity back to medium as this is a legitimate vector to extract value
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 contract uses the instantaneous reserves from a Uniswap pair to calculate voting power, which can be manipulated within a single transaction.
Impact
If voting power is used for governance, an attacker could increase their voting power and pass a proposal; however, the exploit may be limited if balanceOf is only called by a trusted EOA, but frontrunning is still possible.
What the attacker needed
Access to Uniswap pool; voting power used in governance
The fix
The contract should use a time-weighted average reserve amount (TWAP) instead of instantaneous reserves to prevent manipulation.
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.
This contract gives you voting power based on how many tokens you have in a Uniswap pool. But someone can quickly add tokens to the pool, take a snapshot of their voting power, and then remove the tokens. This lets them cheat the voting system.
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.