sherlock-audit / 2023-12-flatmoney-judging

9 stars 7 forks source link

Avci - Users can call executeOrder() function without paying the Pyth network fee #276

Closed sherlock-admin2 closed 5 months ago

sherlock-admin2 commented 5 months ago

Avci

high

Users can call executeOrder() function without paying the Pyth network fee

Summary

there is no check in the updatePythPrice() function that ensures the user msg.value is enough to pay the Phyth network fee.

Vulnerability Detail

someone calls executeOrder() function with zero msg.value, updatePythPrice() modifier calls updatePythPrice() function with msg.value (which is zero), updatePythPrice() function gets fee amount and pays the Pyth network fee and finally checks msg.value for refund. but we can see there is no check for msg.value that not less than fee amount. As a result OracleModule.sol contract pays fee instead of the caller.

Impact



https://github.com/sherlock-audit/2023-12-flatmoney/blob/bba4f077a64f43fbd565f8983388d0e985cb85db/flatcoin-v1/src/DelayedOrder.sol#L378-L410

https://github.com/sherlock-audit/2023-12-flatmoney/blob/bba4f077a64f43fbd565f8983388d0e985cb85db/flatcoin-v1/src/abstracts/OracleModifiers.sol#L12-L22

https://github.com/sherlock-audit/2023-12-flatmoney/blob/bba4f077a64f43fbd565f8983388d0e985cb85db/flatcoin-v1/src/OracleModule.sol#L64-L76
## Tool used

Manual Review

## Recommendation
Consider checking msg.value>=fee. very simple.
sherlock-admin commented 5 months ago

1 comment(s) were left on this issue during the judging contest.

takarez commented:

invalid

nevillehuang commented 4 months ago

Invalid, see out of scope updatePriceFeeds(), where fee needs to be paid, see here