Submitted by 3docSec
The IOracle.queryExchangeRate offers the following lookup functionality, in analogy to other oracles like Chainlinks:
If we focus on the blockTimeMs returned value, this is meant to correspond to the time when the price was last updated and, in analogy to how Chainlink oracles are typically used, is most likely to be used in staleness checks.
If we see how this is implemented, we see that values are passed through from OracleKeeper (L92):
However, the blockTime returned by oracleKeeper.GetDatedExchangeRate corresponds to the current block time and, therefore, does not correspond to what should be returned by the precompile, that is the block time of the last price update.
The impact of this misalignment is quite severe because since the returned value is the timestamp returned is always that of the current block, the price will always look as freshly set when validated against blockTime, which is the most common validation. Consequently, downstream contracts will likely always pass staleness checks on potentially extremely old prices.
A simple coded PoC for this issue consists of updating the TestOracle_HappyPath test in x/evm/precompile/oracle_test.go to simulate a precompile call at a later block than that of the price update.
Changing L66 as follows will cause the test to fail:
Consider maintaining and querying a lookup table (height to time) for returning the right blockTime instead of relying on the value passed by GetDatedExchangeRate.
Unique-Divine (Nibiru) commented:
Unique-Divine (Nibiru) confirmed and commented:
berndartmueller (judge) decreased severity to Medium and commented:
Nibiru mitigated:
Status: Mitigation confirmed. 
For this audit, 2 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by Bauchibred received the top score from the judge.
The following wardens also submitted reports: Rhaydden.
