safeApprove() for Yearn Vault may revert preventing deposits causing DoS
Submitted by 0xRajeev, also found by pauliax
The _depositInVault() function for Yearn yield source uses ERC20 safeApprove() from OpenZeppelin’s SafeERC20 library to give maximum allowance to the Yearn Vault address if the current allowance is less than contract’s token balance.
However, the safeApprove function prevents changing an allowance between non-zero values to mitigate a possible front-running attack. It reverts if that is the case. Instead, the safeIncreaseAllowance and safeDecreaseAllowance functions should be used. Comment from the OZ library for this function:
“//
safeApproveshould only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // ‘safeIncreaseAllowance’ and ‘safeDecreaseAllowance’”
If the existing allowance is non-zero (say, for e.g., previously the entire balance was not deposited due to vault balance limit resulting in the allowance being reduced but not made 0), then safeApprove() will revert causing the user’s token deposits to fail leading to denial-of-service. The condition predicate indicates that this scenario is possible. See similar Medium-severity finding M03.
Recommend using safeIncreaseAllowance() function instead of safeApprove().
kamescg (PoolTogether) confirmed and patched:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity doS bug in PoolTogether. Code4rena made it public on 16 September 2021. Found in the 2021-06-pooltogether audit contest (finding M-01).
About DoS
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.