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:
The condition always evaluates to true due to the nature of recipient addresses used in token swap operations.
As a result, the contract always reverts with the WrongRecipient error, regardless of the actual recipient address.
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.
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 thePrelaunchPoints
contract can lead to unintended contract behavior. Specifically, the contract will always revert with theWrongRecipient
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 thePrelaunchPoints
contract:The issue arises from the condition
recipient != address(this) && recipient != address(0)
, which expectsrecipient
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 therecipient
variable in the context of token swaps.Impact of the Vulnerability:
true
due to the nature of recipient addresses used in token swap operations.WrongRecipient
error, regardless of the actual recipient address.Tools Used
Manual Review
Recommended Mitigation Steps
To mitigate this vulnerability, the condition in the
_validateData
function regarding therecipient
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