Calls to Oracles don't check for stale prices
The oracle price feed calls in several contracts do not check whether the returned price is stale. An attacker could exploit a stale price to cause incorrect calculations in key functions of the USSD and USSDRebalancer contracts.
Source: https://github.com/sherlock-audit/2023-05-USSD-judging/issues/31
Found by
0x2e, 0xHati, 0xPkhatri, 0xRobocop, 0xSmartContract, 0xStalin, 0xeix, 0xlmanini, 0xyPhilic, Angry_Mustache_Man, Aymen0909, Bauchibred, Bauer, Brenzee, BugBusters, Delvir0, DevABDee, Diana, Dug, Fanz, GimelSec, HonorLt, J4de, Kodyvim, Kose, Lilyjjo, Madalad, MohammedRizwan, Nyx, PNS, PTolev, Pheonix, PokemonAuditSimulator, Proxy, RaymondFam, Saeedalipoor01988, SaharDevep, SanketKogekar, Schpiel, T1MOH, TheNaubit, VAD37, WATCHPUG, __141345__, ast3ros, berlin-101, capy_, chainNue, chaithanya_gali, chalex.eth, ctf_sec, curiousapple, dacian, evilakela, georgits, giovannidisiena, immeas, josephdara, juancito, kiki_dev, kutugu, lil.eth, martin, ni8mare, nobody2018, pavankv241, peanuts, qbs, qckhp, saidam017, sakshamguruji, sam_gmk, sashik_eth, sayan_, shaka, shealtielanz, simon135, ss3434, tallo, theOwl, toshii, tsvetanovv, twicek, ustas, vagrant, w42d3n, warRoom, whiteh4t9527
Summary
Calls to Oracles don't check for stale prices.
Vulnerability Detail
None of the oracle calls check for stale prices, for example StableOracleDAI.getPriceUSD():
(, int256 price, , , ) = priceFeedDAIETH.latestRoundData();
return
(wethPriceUSD * 1e18) /
((DAIWethPrice + uint256(price) * 1e10) / 2);
Impact
Oracle price feeds can become stale due to a variety of reasons. Using a stale price will result in incorrect calculations in most of the key functionality of USSD & USSDRebalancer contracts.
Code Snippet
StableOracleDAI.getPriceUSD() StableOracleWBGL.getPriceUSD() StableOracleWBTC.getPriceUSD() StableOracleWETH.getPriceUSD()
Tool used
Manual Review
Recommendation
Read the updatedAt parameter from the calls to latestRoundData() and verify that it isn't older than a set amount, eg:
if (updatedAt < block.timestamp - 60 * 60 /* 1 hour */) {
revert("stale price feed");
}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
Using a stale price could result in incorrect calculations in most of the key functionality of USSD and USSDRebalancer contracts.
What the attacker needed
Oracle price becomes stale
The fix
The code should read the updatedAt parameter from latestRoundData() and revert if the price is older than a set threshold, such as one hour.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Smart contracts often rely on external services called oracles to get current prices. If the oracle returns an old price, the contract might make decisions based on outdated information, which can be exploited. This report points out that the code never checks how old the price is.