Submitted by Respx
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L224-L258
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L271-L289
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L187-L194
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L201-L222
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-periphery.sol#L487-L593
There is insufficient resilience in the design for the case where there has been no call to _update() for a long time. Consider these possible scenarios:
In any of these scenarios, it is possible that the price of any non-stablecoin token might be prone to serious volatility, $CANTO in particular.
The system has no provision for this issue.
Consider the following attack scenario:
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L224-L258
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L271-L289
reserves(), sampleReserves() and sampleSupply() make no use of block.timestamp. They all measure only the time duration of the observations. There is no awareness of how much time has passed since the most recent observation was made.
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L187-L194
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L201-L222
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-periphery.sol#L487-L593
quote() and sample() have the same logic, and these functions are called in getPriceCanto() and getPriceNote(). getPriceLP() relies on sampleReserves(). They therefore have the same issue.
The system could track the average duration time of observations and, if any of the observations in a sample are significantly greater than this average, the system could either refuse to return a sample, or could return a warning flag to indicate that the sample data could be unreliable.
There is precedent in the system for refusing to return a sample (see line 242 of BaseV1-core.sol).
nivasan1 (Canto) disputed and commented:
0xean (judge) decreased severity to Medium and commented:
For this contest, 51 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by lukris02 received the top score from the judge.
The following wardens also submitted reports: p_crypt0, Dravee, hickuphh3, Deivitto, ajtra, Bnke0x0, Rolezn, tnevler, fatherOfBlocks, rvierdiiev, rbserver, ReyAdmirado, 0xNazgul, erictee, oyc_109, 0x52, Chom, Tomo, gogo, cryptphi, CodingNameKiki, SinceJuly, 0x1f8b, peritoflores, TomJ, 0xA5DF, codexploder, Bronicle, ignacio, Jeiwan, hansfriese, a12jmx, hake, R2, rokinot, RaymondFam, 0xSky, ontofractal, pashov, csanuragjain, Diraco, rajatbeladiya, CertoraInc, ak1, JansenC, Yiko, IgnacioB, 0x040, EthLedger, JC.
