40,000 USDC
View results
Submission Details
Severity: high

Incorrect implementation of the onlyBuyerOrSeller modifier leads to unexpected reverts

Summary

The onlyBuyerOrSeller modifier is designed to ensure than only the buyer or the seller can initiate a dispute, but due to incorrect implementation neither the buyer or the seller will be able to initiate a dispute.

Vulnerability Details

/// @dev Throws if called by any account other than buyer or seller.
modifier onlyBuyerOrSeller() {
if (msg.sender != i_buyer && msg.sender != i_seller) {
revert Escrow__OnlyBuyerOrSeller();
}
_;
}

This current implementation will revert if the caller is not i_buyer AND i_seller which is incorrect.

Impact

Disputes between buyers and sellers can never be initiated, rendering the initiateDispute() function useless.

Tools Used

Manual

Recommendations

Use || instead of && like so:

/// @dev Throws if called by any account other than buyer or seller.
modifier onlyBuyerOrSeller() {
if (msg.sender != i_buyer || msg.sender != i_seller) {
revert Escrow__OnlyBuyerOrSeller();
}
_;
}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.