Buoy3Pool.safetyCheck is not precise and has some assumptions
The safetyCheck function in Buoy3Pool only compares the a/b and a/c ratios, which does not guarantee that the b/c ratio is within the allowed range. This imprecision could cause the contract to incorrectly halt deposits or withdrawals.
Submitted by cmichel, also found by shw
The safetyCheck function has several issues that impact how precise the checks are:
- Only checks if the
a/banda/cratios are withinBASIS_POINTS. By transitivity,b/cis only within2 * BASIS_POINTSifa/banda/care in range. For a more precise check whether both USDC and USDT are within range,b/cmust be checked as well. - If
a/bis within range, this does not imply thatb/ais within range. -
“inverted ratios, a/b bs b/a, while producing different results should both reflect the same change in any one of the two underlying assets, but in opposite directions”
- Example:
lastRatio = 1.0ratio: a = 1.0, b = 0.8=>a/b = 1.25,b/a = 0.8Ifa/bwas used with a 20% range, it’d be out of range, butb/ais in range. - The NatSpec for the function states that it checks Curve and an external oracle, but no external oracle calls are checked, both
_ratioandlastRatioare only from Curve. Only_updateRatioschecks the oracle.
To address this issue, it is recommended to check if b/c is within BASIS_POINTS .
kristian-gro (Gro) confirmed but disagreed with severity:
Makes strong assumption about the range of possible values - small differences between a and b will result in small differences between a/b and b/a - Extreme cases are handled by emergency. Agree on b/c check
medium severity - will only cause stop of deposits/withdrawals against curve, work around to put in emergency mode
kristian-gro (Gro) commented:
Acknowledged, but the differences between variables are in basis points, we’ve simulated flash loan manipulations of curve and come to the conclusion that this approximation has a sufficiently small error margin to not cause issues. The B/C check (usdc/usdt) has been added in release version.
A possibility of stopping deposits or withdrawals deserves high risk.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The check only verifies two of the three possible pairwise ratios, so the third ratio can be out of range without being detected.
Impact
This could cause deposits or withdrawals to be stopped, but the team argues the error margin is small and extreme cases are handled by emergency mode.
What the attacker needed
None
The fix
The b/c check was added in the release version.
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.
This is a smart contract that checks if the prices of three stablecoins are close enough to each other. It only compares two pairs of prices, but not the third pair, so it might think everything is fine when one pair is actually too far apart. That could make the contract stop working for deposits and withdrawals.
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.