Closed howlbot-integration[bot] closed 4 months ago
koolexcrypto marked the issue as duplicate of #18
koolexcrypto changed the severity to 2 (Med Risk)
koolexcrypto marked the issue as partial-50
koolexcrypto marked the issue as partial-25
koolexcrypto marked the issue as partial-50
koolexcrypto changed the severity to 3 (High Risk)
koolexcrypto marked the issue as duplicate of #33
koolexcrypto marked the issue as partial-25
Lines of code
https://github.com/code-423n4/2024-05-loop/blob/0dc8467ccff27230e7c0530b619524cc8401e22a/src/PrelaunchPoints.sol#L257-L266 https://github.com/code-423n4/2024-05-loop/blob/0dc8467ccff27230e7c0530b619524cc8401e22a/src/PrelaunchPoints.sol#L491-L505
Vulnerability details
Impact
When a user claims a non-ETH token, the
_claim
function incorrectly calculates the amount of lpETH to be minted and transferred to the user. If the contract holds any ETH balance before the token swap, this pre-existing ETH will be included in the lpETH minting, resulting in the user receiving more lpETH than they should. This could lead to inflation of the lpETH supply and loss of funds for the protocol.Proof of Concept
The
_claim
function in the contract assumes that the entire ETH balance of the contract after a token-to-ETH swap is the result of that swap. This is incorrect if the contract already held some ETH before the swap. Here's the relevant part of the code: https://github.com/code-423n4/2024-05-loop/blob/0dc8467ccff27230e7c0530b619524cc8401e22a/src/PrelaunchPoints.sol#L257-L266Let's consider the following scenario:
claim
function to claim 1000 tokens of a non-ETH token, with a_percentage
of 100._claim
function calculatesuserClaim
as 1000 tokens and calls_fillQuote
to swap these tokens for ETH._fillQuote
function performs the swap and receives 5 ETH in return._claim
function then calculatesclaimedAmount
as the entire balance of the contract (15 ETH) and mints 15 lpETH to the user.However, the user should only receive 5 lpETH, as that's the amount of ETH received from swapping their claimed tokens. The extra 10 ETH should not be included in the minting.
Tools used
Manual review
Recommended Mitigation Steps
Modify the
_claim
function to track the ETH balance before and after the swap, and only convert the difference to lpETH by adjusting the_fillQuote
function to return the amount of ETH bought, and using this value in the_claim
function:Assessed type
ETH-Transfer