code-423n4 / 2024-05-loop-findings

4 stars 4 forks source link

Wrong `if` statement in the `_validateData` function causes the `claim` function always to revert when claiming tokens that are not ETH #12

Closed howlbot-integration[bot] closed 5 months ago

howlbot-integration[bot] commented 6 months ago

Lines of code

https://github.com/code-423n4/2024-05-loop/blob/main/src/PrelaunchPoints.sol#L439

Vulnerability details

Impact

The vulnerability identified in the _validateData function of the PrelaunchPoints contract can lead to unintended contract behavior. Specifically, the contract will always revert with the WrongRecipient error due to a misleading condition in the code. This can prevent expected functionality related to token swaps and recipient validation.

Proof of Concept

The vulnerability can be found in the _validateData function within the PrelaunchPoints contract:


function _validateData(address _token, uint256 _amount, Exchange _exchange, bytes calldata _data) internal view {
    // Other code omitted for brevity

    if (recipient != address(this) && recipient != address(0)) {    // Incorrect condition
        revert WrongRecipient(recipient);
    }
}

The issue arises from the condition recipient != address(this) && recipient != address(0), which expects recipient to be neither the contract's address (address(this)) nor the zero address (address(0)). However, this condition does not align with the expected behavior of the recipient variable in the context of token swaps.

Impact of the Vulnerability:

Tools Used

Manual Review

Recommended Mitigation Steps

To mitigate this vulnerability, the condition in the _validateData function regarding the recipient address check should be revised to align with the actual use case of the recipient address in token swap scenarios. Considerations for valid recipient addresses in token swaps should be made to ensure smooth contract functionality without unnecessary reverts.

Assessed type

Invalid Validation

0xd4n1el commented 5 months ago

The if statement is correct

c4-judge commented 5 months ago

koolexcrypto marked the issue as unsatisfactory: Invalid