Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buoy3Pool.safetyCheck is not precise and has some assumptions #104

Open
code423n4 opened this issue Jul 7, 2021 · 3 comments
Open

Buoy3Pool.safetyCheck is not precise and has some assumptions #104

code423n4 opened this issue Jul 7, 2021 · 3 comments

Comments

@code423n4
Copy link
Contributor

Handle

cmichel

Vulnerability details

Vulnerability Details

The safetyCheck function has several issues that impact how precise the checks are:

  1. only checks if the a/b and a/c ratios are within BASIS_POINTS.
    By transitivity b/c is only within 2 * BASIS_POINTS if a/b and a/c are in range.
    For a more precise check whether both USDC and USDT are within range, b/c must be checked as well.

  2. If a/b is within range, this does not imply that b/a is 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.0
ratio: a = 1.0, b = 0.8 => a/b = 1.25, b/a = 0.8
If a/b was used with a 20% range, it'd be out of range, but b/a is in range.

  1. The natspec for the function states that it checks Curve and an external oracle, but no external oracle calls are checked, both _ratio and lastRatio are only from Curve. Only _updateRatios checks the oracle.

Recommended Mitigation Steps

In addition, check if b/c is within BASIS_POINTS.

@code423n4 code423n4 added 3 (High Risk) bug Something isn't working labels Jul 7, 2021
code423n4 added a commit that referenced this issue Jul 7, 2021
@kitty-the-kat kitty-the-kat added the duplicate This issue or pull request already exists label Jul 14, 2021
@kitty-the-kat
Copy link
Collaborator

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

@kitty-the-kat kitty-the-kat added disagree with severity and removed duplicate This issue or pull request already exists labels Jul 14, 2021
@kitty-the-kat
Copy link
Collaborator

medium severity - will only cause stop of deposits/withdrawals against curve, work around to put in emergency mode

@ghoul-sol
Copy link
Collaborator

A possibility of stopping deposits or withdrawals deserves high risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants