Beanstalk implements "invariant" modifiers that makes sure the invariants of the protocol hold "true" in all cases. Since the protocol is a complex one, this adds additional layer of security during function executions. However if we look at the fundsSafu
modifier (which checks how much "debt" it owes to users and if it has enough to return in case of withdrawals), in short it retrieves the tokens which accrue interest over time and checks their balances.
As can be observed in the code snippets above, the modifier makes calls to functions, which contain multiple loops, especially the Invariable::getTokenEntitlementsAndBalances
is large and complex one. This drastically increases the gas costs for the modifier's successful execution, which can make it exceed the block gas limit. Moreover the whitelisted tokens can grow in size, and also first the function logic is executed (where the fundsSafu
modifier is put in) and then the modifier logic, all this increases the chances reaching the block gas limit, which is currently 30m on Mainnet.
The functions which include the fundsSafu
modifier (which is basically every public or external function) can simply revert every time.
Impact: High, DoS or high gas costs for users
Likelihood: Low, as it requires large arrays length
Overall: Medium
Manual Review
Limit the size of the arrays to reasonable amount, which looping through will not exceed the 30m threshold.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.