Witty Cinnamon Barracuda
Medium
No response
https://github.com/sherlock-audit/2024-11-oku/blob/main/oku-custom-order-types/contracts/automatedTrigger/Bracket.sol#L456C1-L462C1
modifyOrder
function only checks for the presence of an oracle for the new _tokenOut
if, and only if, it differs from the original tokenOut
Let's say Alice wants to trade ETH for LINK. Assume both ETH and LINK have valid oracle registrations when she starts.
-
Alice Creates an Order: Alice calls
createOrder
to set up a bracket order. She specifies:tokenIn
: ETH (has a valid oracle)tokenOut
: LINK (has a valid oracle)takeProfit
: 2 ETH per LINK (the price at which she wants to sell)stopPrice
: 1.5 ETH per LINK (the price at which she wants to exit to limit losses)
Because both ETH and LINK initially have oracles, her order is created without issues.
require(
address(MASTER.oracles(tokenIn)) != address(0x0) &&
address(MASTER.oracles(tokenIn)) != address(0x0),//@audit used same tokenIn
"Oracle !exist"
);
- LINK Oracle Malfunctions: A few hours later, there's a problem with the LINK oracle. Maybe it's temporarily down, or perhaps it was deliberately compromised. The point is, the LINK price feed is no longer available.
- Alice Modifies Her
stopPrice
: Alice decides she wants to adjust herstopPrice
to 1.7 ETH per LINK. She callsmodifyOrder
, providing the newstopPrice
but keeping the sametokenOut
(LINK). - The Missing Check: Because
modifyOrder
only checks for a valid oracle if thetokenOut
is changed, it doesn't notice that the LINK oracle is now gone. Alice's order is updated with the newstopPrice
, but it now points to atokenOut
with a broken price feed. - Order Execution Attempt: Later, the
checkUpkeep
function runs, trying to determine if Alice's order should be triggered. It callscheckInRange
, which needs to get the current ETH/LINK exchange rate. - Failure: The system tries to get the ETH/LINK price from the
MASTER
contract, but the LINK oracle. Alice's order fails to execute. IfgetExchangeRate
doesn't revert but instead returns incorrect value, Alice's order could execute at a completely unintended price, resulting in financial losses.
No response
No response
No response
No response
No response
require(
address(MASTER.oracles(tokenIn)) != address(0x0) &&
address(MASTER.oracles(tokenOut)) != address(0x0),
"Oracle !exist"
);