sherlock-audit / 2024-08-flayer-judging

2 stars 0 forks source link

Raspy Azure Dragonfly - Swap bypass check #807

Closed sherlock-admin4 closed 1 month ago

sherlock-admin4 commented 1 month ago

Raspy Azure Dragonfly

Low/Info

Swap bypass check

Summary

The swapBatch function in the contract allows users to swap multiple NFTs at once. However, there is a missing validation check within the function, allowing the bypass of the same-token swapping restriction that exists in the single swap function. This creates an unintended discrepancy in behavior between the two functions and introduces a potential vulnerability where a user could perform an unnecessary or unintended swap by exchanging the same token.

Vulnerability Detail

In the swap function, a check is implemented to ensure that a user cannot swap a token for itself:

if (_tokenIdIn == _tokenIdOut) revert CannotSwapSameToken();

However, in the swapBatch function, there was an ommision of this check; This omission allows users to swap the same token with itself, which not only contradicts the logic of the single token swap function but could also result in confusion or unintended behavior. For example, a user could initiate a batch swap where some token pairs involve identical tokens, which serves no purpose and could result in unnecessary gas costs or unexpected state changes.

Impact

Manual Review

Recommendation

Ensure this check is properly implemented in the sawpBatch function

if (_tokenIdsIn[i] == _tokenIdsOut[i])
    revert CannotSwapSameToken();