TransferHelper.safeApprove(_token, _target, _amount);
does not approve 0 first.
#1892
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-1662
edited-by-warden
low quality report
This report is of especially low quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/libraries/TransferHelper.sol#L6-L15
https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/amo/UniV3LiquidityAmo.sol#L146-L148
https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/reLP/ReLPContract.sol#L150-L163
Vulnerability details
Impact
These are the functions that call
TransferHelper.safeApprove
and can be reverted due toSafeERC20.safeApprove
. It makes impossible to change just one address forReLPContract
andPerpetualAtlanticVault
.ReLPContract.setAddresses
V3Amo.approveTarget
PerpetualAtlanticVault.setAddress
reverts if called twice and some arguments remain the same. This is shown below.Proof of Concept
The comment says it approves 0 first, but actually
TransferHelper.safeApprove
does not approves 0 first.https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/libraries/TransferHelper.sol#L6-L15
Add
tests/perp-vault/POC.sol
and runforge test --mt test_setAddresses
.Tools Used
Manual, foundry
Recommended Mitigation Steps
SafeERC20.forceApprove
. It approves 0 if necessary. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol#L76SafeERC20.increaseAllowance
anddecreaseAllowance
instead.Assessed type
Other
The text was updated successfully, but these errors were encountered: