Closed sherlock-admin closed 1 year ago
Escalate for 10 USDC Similarly to 411, https://github.com/sherlock-audit/2023-01-derby-judging/issues/411#issuecomment-1503876217, yield might include reward tokens, that will be sent to YearnProvider or AaveProvider by the pool on withdrawal and then be stolen from Provider balance as described in the issue.
For example, Aave currently have pools with reward tokens being part of the yield in addition to underlying:
This looks like valid high severity and needs to be fixed.
Escalate for 10 USDC Similarly to 411, https://github.com/sherlock-audit/2023-01-derby-judging/issues/411#issuecomment-1503876217, yield might include reward tokens, that will be sent to YearnProvider or AaveProvider by the pool on withdrawal and then be stolen from Provider balance as described in the issue.
For example, Aave currently have pools with reward tokens being part of the yield in addition to underlying:
This looks like valid high severity and needs to be fixed.
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Escalation accepted
Considering this issue a duplicate of #411
Escalation accepted
Considering this issue a duplicate of #411
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
hyh
high
Any tokens can be stolen via withdraw from YearnProvider and AaveProvider balances
Summary
In both cases the amount to be returned to a user is determined by responses of another user-supplied contract.
Vulnerability Detail
Attacker calling YearnProvider and AaveProvider withdraw() can supply real
_uToken
and precooked_yToken
/_aToken
that will report the numbers needed to fully extract_uToken
balance of the Provider._uToken
can be any, there looks to be no preconditions.Simplest example is rewards supplied by yield market via any LP initiative program can be stolen by a third party. Say, for example, such reward funds can be sent to some Providers on Vault withdrawals via them and are left on their balances.
Impact
Any underlying tokens can be stolen fully from YearnProvider and AaveProvider balances.
Even if all these contracts aren't supposed to hold balances, there are a spectre of cases when they end up possessing some meaningful funds (accumulated residuals, additional rewards supplied from the markets, user operational mistakes), which are attributed to protocol users, but can be stolen this way.
Code Snippet
Fake
_yToken
supplied to YearnProvider's withdraw() reports back current real_uToken
balance of YearnProvider viaIYearn(_yToken).withdraw(_amount)
, which is then send tomsg.sender
:https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/Providers/YearnProvider.sol#L44-L66
Fake
_aToken
supplied to AaveProvider's withdraw() reports real pool and_uToken
addresses, reports balances so that_amount
is the difference. As result currentreal_aToken
balance of AaveProvider will be withdrawn tomsg.sender
:https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/Providers/AaveProvider.sol#L49-L74
Tool used
Manual Review
Recommendation
One way is maintaining a whitelist mapping {underlying token -> yield bearing token -> acceptance flag}. The flag for the pair used in a call is then required for withdraw to proceed.
Also, a balance check for token that is sent to a user can be useful: for attacker to benefit the token that is sent to them has to be real, so another approach is controlling its balance of the contract before and after the operation, and require that no loss of the initial balance took place.
Duplicate of #411