depositFor() in CrvDepositor, call arbitrary external contract which can be harmful for contract funds or user can lose funds incase of wrong address #309
Labels
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
duplicate
This issue or pull request already exists
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Lines of code
https://github.com/code-423n4/2022-05-aura/blob/4989a2077546a5394e3650bf3c224669a0f7e690/convex-platform/contracts/contracts/CrvDepositor.sol#L168-L203
Vulnerability details
Impact
If user set wrong value for
_stakeAddress
his fund can be lost because contract don't check the value and transfer user minted tokens to that address.attacker can set
_stakeAddress
and make contract call arbitrary contract'sstakeFor()
function. for example ifBalancer
had somestakeFor
functionality, attacker can call that contract and make use ofCrvDepositor
balances inBalancer
.CrvDepositor
deposits tokens incrvBpt
and attacker can makeCrvDepsitor
to callBalancer
protocol contract'sstakeFor()
functions and mint himself some tokens inBalancer
byCrvDepositor
assets, asCrvDepositor
callsBalancer
soBalancer
will allow that action. for this attack there should bestakeFor(to, amount)
function inBalancer
that usescrvBpt
balance.Proof of Concept
This is
depositFor()
code inCrvDepositor
:As you can see there is no check for
_stakeAddress
, and in the end contract callsIRewards(_stakeAddress).stakeFor(to,_amount)
, and attacker can control all these variables.CrvDepositor
deposit user's tokens incrvBpt
pool ofBalancer
. so if there were some functionstackFor()
inBalancer
pool system, attacker can set that contract address as_stakeAddress
, andCrvDepositor
will call that function of that address and attacker can mint himself some other tokens and funds ofCrvDepositor
can be lost and he follow up calculations inCrvDepositor
would be messed up too.Of course if user set
_stakeAddress
wrong value, he can lost his deposits too.Tools Used
VIM
Recommended Mitigation Steps
have some validity checks for
_stakeAddress
and make sure address registered inAura
systesm.The text was updated successfully, but these errors were encountered: