Submitted by 0xRajeev, also found by pauliax
The _depositInVault() function for Yearn yield source uses ERC20 safeApprove() from OpenZeppelins SafeERC20 library to give maximum allowance to the Yearn Vault address if the current allowance is less than contracts token balance.
However, thesafeApprove functionprevents changing an allowance between non-zero valuesto mitigate apossible front-running attack. It reverts if that is the case. Instead, thesafeIncreaseAllowanceandsafeDecreaseAllowancefunctions should be used. Comment from the OZ library for this function:
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 users 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:
