Cyfrin / 2023-07-escrow

17 stars 12 forks source link

`i_price` should be used over `i_tokenContract.balanceOf(address(this)` #876

Closed codehawks-bot closed 11 months ago

codehawks-bot commented 11 months ago

i_price should be used over i_tokenContract.balanceOf(address(this)

Severity

Medium Risk

Relevant GitHub Links

https://github.com/Cyfrin/2023-07-escrow/blob/main/src/Escrow.sol#L98

Summary

i_price should be used over i_tokenContract.balanceOf(address(this)

Vulnerability Details

When the escrow contract is created, the seller should only receive i_price tokens (if there was no arbiter involved). But in the confirmReceipt() method, the seller is sent i_tokenContract.balanceOf(address(this)) tokens, which could be more or less than i_price.

Impact

The seller can be paid less/more if the contract's token balance is different thatn i_price

Tools Used

Manual Code Review

Recommendations

i_price should be used over i_tokenContract.balanceOf(address(this) when paying the amount to the seller

0kage-eth commented 11 months ago