The safetyCheck function of Buoy3Pool checks the two ratios, a/b and a/c, to be healthy but not the ratio b/c. This ratio may be unhealthy, causing assets (USDC, USDT) to be exchanged at a not-so-good price.
Proof of Concept
Consider the following situation:
lastRatio[1] and lastRatio[2] are both 1000000 (i.e., price of DAI == USDC == USDT).
Now, the state of Curve 3pool is slightly imbalanced, with the price USDC > DAI > USDT. The ratio a/b is 998000, and the ratio a/c is 1002000.
Both a/b and a/c are within tolerance (i.e., the difference between itself and its previous value does not exceeds BASIS_POINTS). However, the ratio b/c is not because it differs from the previous value by approximately 2 * BASIS_POINTS.
Handle
shw
Vulnerability details
Impact
The
safetyCheck
function ofBuoy3Pool
checks the two ratios,a/b
anda/c
, to be healthy but not the ratiob/c
. This ratio may be unhealthy, causing assets (USDC, USDT) to be exchanged at a not-so-good price.Proof of Concept
Consider the following situation:
lastRatio[1]
andlastRatio[2]
are both 1000000 (i.e., price of DAI == USDC == USDT).a/b
is 998000, and the ratioa/c
is 1002000.a/b
anda/c
are within tolerance (i.e., the difference between itself and its previous value does not exceedsBASIS_POINTS
). However, the ratiob/c
is not because it differs from the previous value by approximately2 * BASIS_POINTS
.Referenced code: Buoy3Pool.sol#L87-L96
Recommended Mitigation Steps
Check the ratio of
b/c
to ensure it is also healthy.