MagicLpAggregator can be incompatible with potential integrators due to incorrect latestRoundData function
The MagicLpAggregator's latestRoundData function returns zero for roundId, startedAt, updatedAt, and answeredInRound, which can cause integrations that check updatedAt for staleness to revert. An attacker could not directly exploit this, but it breaks compatibility with potential integrators.
Therefore any integrator that uses the above code will not be able to integrate MagicLpAggregator oracles as it will always revert due to the incorrect updatedAt being provided.
Recommended Mitigation Steps
Use the values roundId, startAt, updatedAt and answeredInRound from whichever oracle, baseOracle or quoteOracle was used.
I think we should reiterate the issue here as the submission has tried its best to point out:
The MagicLpAggregator gets the price from Chainlink’s Feed
Integrators (for example protocol A) query the MagicLPAggregator Oracle for price specifically the latestRoundData() function it exposes in their implementation
They make sure the prices returned are fresh and so do well to check the time specifically updatedAt so they can be sure the feed is fresh to proceed with utilizing the returned data
Since the updatedAt as well as other returned data are hardcoded to 0 in MagicLpAggregator oracle implementation, the call reverts. 0 will always be less than block.timestamp - 60 * 60
The step by step description of the issue above I believe is sufficient but here’s a provided POC to elaborate on this in code:
Test file in the abracadabra codebase is: MagicLPAggregator.t.sol
function testProtocolAIntegrationOfMagicLPAggReverts() public {
// return values of `MagicLpAggregator` latestRoundData()
(uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) = aggregator.latestRoundData();
// protocol A tries to make sure the prices returned is fresh by checking the time
// keep in mind the time aka updatedAt is hardcoded to 0. So 0 will always be less than `block.timestamp - 60 * 60` hence a revert
if (updatedAt < block.timestamp - 60 * 60 /* 1 hour */) {
revert("stale price feed");
}
}
Ran 1 test for test/MagicLpAggregator.t.sol:MagicLpAggregatorTest
[FAIL. Reason: revert: stale price feed] testProtocolAIntegrationOfMagicLPAggReverts() (gas: 57187)
Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 2.56s (2.88ms CPU time)
latestRoundData() is different from the standard and may cause integration issues. Will consider it a valid M.
The original report as published on Code4rena, by DarkTower. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The latestRoundData function hardcodes the roundId, startedAt, updatedAt, and answeredInRound values to zero instead of returning the actual values from the underlying oracles.
Impact
Integrators that check updatedAt for staleness will always revert, making the oracle unusable for them.
What the attacker needed
Integrator checks updatedAt for staleness
The fix
The latestRoundData function should return the roundId, startedAt, updatedAt, and answeredInRound values from the baseOracle or quoteOracle that was used.
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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A price oracle is a service that provides price data to smart contracts. The MagicLpAggregator is such an oracle, but its latestRoundData function returns zeros for the timestamp fields instead of real times. If another contract checks that the price is recent by comparing the timestamp to the current time, it will always see zero and think the price is stale, so it will refuse to use it.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.