Closed code423n4 closed 2 years ago
Probably better to use infinite approval here to save on gas also 😃
The warden asserts that the code will revert if allowance is non-zero, that is indeed a property of safeApprove
However, no attempt is made at showing any situation in which allowance will be non-zero to non-zero.
The code for depositFees
is available and shows that the transfer will be for the full amount.
In lack of a demonstration of the code reverting I think the finding is invalid.
Lines of code
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/RewardHandler.sol#L52
Vulnerability details
Impact
Transaction reverting.
Proof of Concept
OZ's implementation of safeApprove would throw an error if an approve is attempted from a non-zero value (
"SafeERC20: approve from non-zero to non-zero allowance"
): https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol#L53-L56Affected Code
See
@audit
tag:Mitigations
Set the allowance to zero immediately before this
safeApprove()
call: