Closed code423n4 closed 2 years ago
Normally the gauge should distribute CRV and CVX proportional to user's share of totalStaked. In case there are 2000 CVX in the contract, an attacker who own 80% of the share should receive 1600 CVX without an attack. It looks like its possible for the attacker to donate additional 5000 CRV (assuming 90M CVX total supply) such that he can drain the remaining 400 CVX in the contract, which he can recover 5000 * 80% = 4000 CRV for a total cost of 1000 CRV.
Invalid due to out-of-scope. https://github.com/code-423n4/2022-04-backd/blob/main/README.md
Lines of code
https://github.com/code-423n4/2022-04-backd/blob/c856714a50437cb33240a5964b63687c9876275b/backd/contracts/tokenomics/AmmConvexGauge.sol#L185-L212
Vulnerability details
https://github.com/code-423n4/2022-04-backd/blob/c856714a50437cb33240a5964b63687c9876275b/backd/contracts/tokenomics/AmmConvexGauge.sol#L185-L212
In the current implementation,
crvEarned
is the newcrv
reward earned since the last claim.However, anyone can send
crv
tokens to the contract to increasecrvEarned
.Since
cvxEarned
is based oncrvEarned
, by increasingcrvEarned
,cvxStakedIntegral
can be increased artificially.When the increased
cvx
is worth more than thecrv
tokens sent, the attacker can net a profit from it.PoC
Given:
totalStaked
;claimRewards()
:crvEarned
= 10,000cvxEarned
= 2,000Recommendation
Consider updating the
cvxStakedIntegral
aftercrvRewardsContract.getReward();
with the actual amount of CVX tokens received.