Closed code423n4 closed 2 years ago
There is a whitelist on what stable pairs are referenced by the lending market when determining the prices of assets (setStable), this method is only accessible through chain governance. As the getUnderlyingPrice method is specifically designed to be used by the Comptroller, a whitelist on the factory is not needed
closing as invalid.
Lines of code
https://github.com/code-423n4/2022-09-canto/blob/65fbb8b9de22cf8f8f3d742b38b4be41ee35c468/src/Swap/BaseV1-core.sol#L598-L611
Vulnerability details
Impact
Stable and non-stable pair use different formula to calculate the invariant k_. If a non-stable pair is treated as stable, or vice versa.
$x^3y+y^3x$ behave quite differently compare with $xy$, on the edge of relative stable price range, price volatility could be abnormally high. Swap amounts could loss accuracy and be abused. The following results might happen:
Proof of Concept
Stable pair parameter is input by the user, and no checks on if it is true. src/Swap/BaseV1-core.sol
A mistaken input can happen, even worse, malicious user can do it on purpose to take advantage of the k_ calculation.
Tools Used
Manual analysis.
Recommended Mitigation Steps
Use a whitelist for stablecoins, only allow stable pair creation if both tokens are in the whitelist.