Closed code423n4 closed 1 year ago
kyscott18 marked the issue as sponsor disputed
I don't see how this is an issue. The borrower provides a certain amount of token1 as collateral and then receives the calculated amount of lp tokens because the lp tokens are borrowed against this collateral. For convenience, the lp token is withdrawn into the underlying token0 and token1 which is why these tokens are returned to the caller
berndartmueller marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-01-numoen/blob/2ad9a73d793ea23a25a381faadc86ae0c8cb5913/src/core/Lendgine.sol#L91-L93 https://github.com/code-423n4/2023-01-numoen/blob/2ad9a73d793ea23a25a381faadc86ae0c8cb5913/src/periphery/LendgineRouter.sol#L86-L117
Vulnerability details
Impact
Borrower of liquidity can just keep borrowing liquidity as he will also get token0 and token1, draining the protocol funds.
Proof of Concept
Lendgine#mint calls Pair#burn before calling _mint() to mint the number of ERC20 power tokens.
In Pair#burn, the to parameter receives token0 and token1
Pair#burn works with Lendgine#withdraw, because a liquidity provider will 'burn' their liquidity token and get back two tokens. However, Pair#burn does not work with Lendgine#add, because the borrower who wants to mint a Power token with token1 as collateral will not only get the Power token, but also token0 and token1. The function Lendgine#mint then calls LendgineRouter#mintCallback, which transfer the necessary amount of token1 to mint an option position.
When a borrower borrows liquidity, he pays two things. Firstly, he pays token1 as collateral. Secondly, he pays the equivalent borrow rate. Borrower should not get any token0 back.
Tools Used
VSCode
Recommended Mitigation Steps
When borrower is borrowing liquidity, transfer the liquidity to another contract for safekeeping first instead of transferring to the borrower. This way, the borrower will not benefit.