Open sherlock-admin4 opened 9 months ago
2 comment(s) were left on this issue during the judging contest.
panprog commented:
valid medium. dup of #41
takarez commented:
valid; medium(3)
The protocol team fixed this issue in PR/commit https://github.com/dverso/smilee-v2-contracts/commit/84174d20544970309c862a2bf35ccfa3046d6bd9.
Fix review: Fixed
The Lead Senior Watson signed off on the fix.
ZanyBonzy
medium
Mint and sales can be dossed due to lack of safeApprove to 0
Summary
The lack of approval to 0 to the dvp contract, and the fee managers during DVP mints and sales will cause that subsequent transactions involving approval of these contracts to spend the basetoken will fail, breaking their functionality.
Vulnerability Detail
When DVPs are to be minted and sold through the PositionManager, the mint and sell functions are invoked. The first issue appears here, where the DVP contract is approved to spend the basetoken using the OpenZeppelin's
safeApprove
function, without first approving to zero. Further down the line, themint
andsell
functions make calls to the DVP contract to mint and burn DVP respectively.The _mint and _burn functions in the DVP contract approves the fee manager to spend the
fee - vaultFee
/netFee
.This issue here is that OpenZeppelin's
safeApprove()
function does not allow changing a non-zero allowance to another non-zero allowance. This will therefore cause all subsequent approval of the basetoken to fail after the first approval, dossing the contract's minting and selling/burning functionality.OpenZeppelin's
safeApprove()
will revert if the account already is approved and the new safeApprove() is done with a non-zero value.Impact
This causes that after the first approval for the baseToken has been given, subsequent approvals will fail causing the functions to fail.
Code Snippet
https://github.com/sherlock-audit/2024-02-smilee-finance/blob/3241f1bf0c8e951a41dd2e51997f64ef3ec017bd/smilee-v2-contracts/src/DVP.sol#L173 The
_mint
and _burn
functions both send a call to approve the feeManager to "pull" the tokens upon thereceiveFee
function being called. And as can be seen from the snippets, a zero approval is not given first.https://github.com/sherlock-audit/2024-02-smilee-finance/blob/3241f1bf0c8e951a41dd2e51997f64ef3ec017bd/smilee-v2-contracts/src/DVP.sol#L327
https://github.com/sherlock-audit/2024-02-smilee-finance/blob/3241f1bf0c8e951a41dd2e51997f64ef3ec017bd/smilee-v2-contracts/src/periphery/PositionManager.sol#L124
Tool used
Manual Review
Recommendation
forceApprove
functions instead;