-
Notifications
You must be signed in to change notification settings - Fork 2
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
h2134 - Super Pool shares can be inflated by bad debt leading to overflows #266
Comments
This should be mitigated by burning shares initially |
Escalate. This is a valid issue. The only way to burn shares in SuperPool is to withdraw, as shares are burned, the assets are decreased too, therefore |
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
This does not account for Shares burned when SuperPool is initally deployed, using SuperPoolFactory.sol. Not an issue imo. |
Shares burned when SuperPool is initially deployed only helps to mitigate vault inflation attack, however, this report describe a different issue, and the POC shows how exactly the shares are inflated to overflow. |
you're right, this isn't the same. i think the root cause here is the same as #585 but for the SuperPool instead of the Pool as mentioned in the other issue. |
I think this issue is a valid Medium. The reason it is not High is because this involves certain external conditions, such as the occurrence of bad debt liquidations, which would inflate the Super Pool shares. While the overflow potential is significant, it requires multiple bad debt liquidations to occur, making the issue dependent on specific states and not an immediate or guaranteed loss of funds. I am planning to accept the escalation and make this issue Medium. |
Seems like a duplicate of #585 to me, what is the difference? |
This issue is different to 585 since it is regarding SuperPool shares, but they both require the liquidator bots to not work for multiple consecutive instances, even though max LTV is 98% so liquidations will be incentivised. |
I don't think this issue's severity should be determined by #585, protocol's off-chain bots will work only when the the liquidation is profitable, and if not (e.g. major price dump), bad debt liquidation will happen, unlike #585, no consecutive bad debt liquidations are needed, even if there are bot liquidations in between, the issue will eventually occur, and it's not a low likelihood event considering the whole lifetime of a SuperPool. |
I will agree with the comment @0xh2134 Bad debt liquidation can occur with a high TVL and high price volatility, and the bots may not have the initiative to liquidate an asset. There is already a valid issue related to this in this contest. Because of that this issue is Medium severity. I am planning to accept the escalation and make this issue Medium. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
The protocol team fixed this issue in the following PRs/commits: |
h2134
High
Super Pool shares can be inflated by bad debt leading to overflows
Summary
Super Pool shares can be inflated by bad debt leading to overflows.
Vulnerability Detail
Super Pool shares are calculated based on total assets and total supply, i.e$Shares = Deposit Amount * Total Shares / Total Assets$ .
SuperPool.sol#L194-L197:
At the beginning, when user deposits$1000e18$ asset tokens, they can mint $1000e18$ shares. The assets will be deposited into underlying pools and normally
Shares per Token
is expected to be deflated as interest accrues.However, if the borrowed assets are not repaid, bad debt may occur and it can be liquidated by pool owner. As a result,
Total Assets
owned by the Super Pool will be largely reduced, as a result,Shares per Token
can be heavily inflated to a very large value, eventually leading to overflows if bad debt liquidated for several times.Consider the following scenario in PoC:
Total Assets
isTotal Shares
isShares per Token
isTotal Assets
isTotal Shares
isShares per Token
is inflated toShares per Token
will be further inflated.In the case of PoC,$1e78$ ) after just 4 bad debt liquidations:
Shares per Token
can be inflated to be more thanuint256.max
(aroundPlease run the PoC in BigTest.t.sol:
Impact
Shares are inflated by bad debts, the more volatile an asset is, the more likely bad debt occurs. Small bad debt may not be a problem because they can only inflate shares by a little bit, however, a few large bad debts as showed in PoC can cause irreparable harm to the protocol (it is especially so if the asset token has higher decimals), and shares are very likely be inflated to overflow in the long run.
As a result, most of the operations can be blocked, users cannot deposit or withdraw.
Code Snippet
https://github.com/sherlock-audit/2024-08-sentiment-v2/blob/main/protocol-v2/src/SuperPool.sol#L456-L472
Tool used
Manual Review
Recommendation
It is recommended to adjust token/share ratio if it has been inflated to a very large value, but ensure the precision loss is acceptable. For example, if the ratio value is$1000000000000000000000000000000000000$ ($1e36$ ), it can be adjusted to $1000000000000000000$ ($1e18$ ). This can be done by using a dynamic
AdjustFactor
to limit the ratio to a reasonable range:SuperPool.sol#L456-L472:
The text was updated successfully, but these errors were encountered: