Closed code423n4 closed 1 year ago
The finding does not highlight any precise vulnerability, the control flow is fine because the safeTransferFrom
doesn't set "to" to an address that could purposely take advantage of this reentrancy because "to" is equal to "address(this)".
berndartmueller marked the issue as unsatisfactory: Insufficient proof
Lines of code
https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L89-L96 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L124-L130 https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L232-L240
Vulnerability details
Impact
In Add() function, in case of non Eth Base Token, LP Tokens are minted for LP Provider before transferring the Base Token from Provider to Contract. In remove() function, Fractional Tokens are Transferred to LP Provider before Burning the LP Token. In wrap() function, Fractional Tokens are minted for User before transferring the NFT to Contract.
It is always Recommended to finish all internal work first, and only then calling the external function to avoid vulnerabilities due to reentrancy.
Proof of Concept
https://consensys.github.io/smart-contract-best-practices/attacks/reentrancy/
Recommended Mitigation Steps
In add() Function, Base Tokens Should be Transferred Before minting LP Tokens.
Link to code
In remove() function, LP Tokens should be Burned before transferring Fractional Tokens.
Link to code
In wrap() function, NFTs should be transferred to contract before minting Franctional Tokens.
Link to code