-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: returnAsset
exploit
#222
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #222 +/- ##
===========================================
+ Coverage 68.21% 88.08% +19.86%
===========================================
Files 12 12
Lines 623 621 -2
===========================================
+ Hits 425 547 +122
+ Misses 198 74 -124 ☔ View full report in Codecov by Sentry. |
This change was originally introduced to ensure a full redemption was possible right? I think provided we have a way to recover if this maths breaks in full redemption mode then we can be reasonably comfortable. I.e. it may make sense to give the admin super user style power to make calls from the asset manager if needed? You could imagine a function like this: function rawCall(address target, uint256 value, bytes data) external onlyOwner |
So previously when we did the PR, we were relying on an Then during the audit, the auditors recommended us to perform the arithmetic directly (without using an intermediate exchange rate) which probably eliminated this problem. That said, with the testing I've done, I haven't been able to come up with a scenario in which full redemption will fail. Yes I thought of the same regarding introducing |
Assuming the owner is the timelock, it should be acceptable? |
Motivation
code was introduced in test: asset manager corner cases #187
mulDivUp
behaviorin our current production deployment of asset manager, all pairs have redeemed successfully (tokens managed are all 0 from the perspective of the pair), but individual and total shares are more than 0. Of course we have a special case where there was a loss (wasn't strictly increasing)
Potential Solutions
lCurrentShares
is greater than 0lCurrentShares
can be 1, andrShares
can be a really large number. i.e. an attacker can get several shares by letting the asset manager manage its assets, and then still attack usingreturnAsset
rShares > lCurrentShares
check completely, relying on checked arithmetic.token0/1Managed
will be zero.