Closed sherlock-admin closed 8 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid: manipulated as in?
Invalid, you cannot manipulate chainlink price feeds directly due to the way they are designed. If other price feeds are manipulated, that is out of scope of this contests, and even then chainlink will still report an accurate price based on current market conditions, given this price feeds are trusted.
If the market-wide price of an asset is manipulated, Price Feeds will report that price because it accurately reflects the current state of the market—the accurate truth. But if only a small subset of an asset’s underlying market is manipulated (e.g. a few low-liquidity markets), then Chainlink Price Feeds are designed to still report the accurate overall market-wide price, helping protect from such manipulation attempts.
Bauer
high
Slippage protection is missing when executing limit orders
Summary
When executing limit orders, the lack of slippage protection means that if the price from Chainlink is manipulated, the keeper fee could be very high, resulting in users receiving significantly reduced settlement funds.
Vulnerability Detail
The execution time of a limit order is uncertain, so the keeper fee is dynamically calculated during execution. When calling
LimitOrder.executeLimitOrder()
to execute the limit order, the protocol invokes_closePosition()
. Within this function, the protocol verifies that the price of rETH is within the threshold range.Then, it begins calculating the keeper fee. The calculation of the keeper fee involves several steps: firstly, the protocol fetches the price of ETH from Chainlink and calculates the gas fee using this price, converting it to USD.
Secondly, it obtains the price of rETH and calculates the keeper fee by dividing the converted USD fee by the price of rETH.
The validation of rETH ensures it remains within the threshold range. If the price of ETH from Chainlink is manipulated to be significantly high, the keeper fee will also increase substantially. This portion of the keeper fee is deducted from the user's settled margin, potentially resulting in users receiving very low settlement fees and consequently experiencing losses in their funds.
Impact
User fund loss
Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/LeverageModule.sol#L313-L314
Tool used
Manual Review
Recommendation
Implement slippage protection.