The function approveContractToSpend is used to approve a contract to spend a certain amount of tokens. There are some require statements in this function, to sanitize the input.
As can be seen from the validate function call, the _amount passed must be non-zero.
This can cause an issue in a token like CRV. The project aims to provide liquidity on curve and stake those LP tokens to earn CRV tokens which will be used ot pay the premium according to the docs. CRV tokens have a special approve function which has built in race condition prevention and require users to approve a value of 0 before changing the allowance from one non-zero value to another. This can be seen in the approve functionof the CRV token written in vyper as shown below.
Lines of code
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/core/RdpxV2Core.sol#L403-L412
Vulnerability details
Impact
The function
approveContractToSpend
is used to approve a contract to spend a certain amount of tokens. There are some require statements in this function, to sanitize the input.As can be seen from the validate function call, the
_amount
passed must be non-zero.This can cause an issue in a token like CRV. The project aims to provide liquidity on curve and stake those LP tokens to earn CRV tokens which will be used ot pay the premium according to the docs. CRV tokens have a special approve function which has built in race condition prevention and require users to approve a value of 0 before changing the allowance from one non-zero value to another. This can be seen in the
approve
functionof the CRV token written in vyper as shown below.So if the contract has some pending CRV allowance, it will be impossible to change that allowance since an allowance of 0 cannot be set.
Proof of Concept
The linked snippet above shows the live code in the CRV token.
Tools Used
Manual Review
Recommended Mitigation Steps
Allow 0 value approvals
Assessed type
DoS