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

[WP-H4] The collateral assets impounded with settleBadDebt() will be frozen in the insuranceFund contract #101

Closed
code423n4 opened this issue Feb 23, 2022 · 1 comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/MarginAccount.sol#L373-L380

Vulnerability details

In MarginAccount.sol#settleBadDebt(), the collateral assets will be seized and transferred to the insuranceFund contract.

However, there is no way for the liquidity providers of the insuranceFund to get back the collateral assets.

In the current implementation, these collateral assets seized during settleBadDebt() will be frozen in the contract, in essence. They belong to the liquidity providers and they should be able to retrieve them.

https://github.com/code-423n4/2022-02-hubble/blob/ed1d885d5dbc2eae24e43c3ecbf291a0f5a52765/contracts/MarginAccount.sol#L373-L380

for (uint i = 1 /* skip vusd */; i < assets.length; i++) {
    int amount = margin[i][trader];
    if (amount > 0) {
        margin[i][trader] = 0;
        assets[i].token.safeTransfer(address(insuranceFund), amount.toUint256());
        seized[i] = amount.toUint256();
    }
}

Recommendation

Consider adding a new method for the liquidity providers to claim certain collateral assets proportionally to the shares they held.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Feb 23, 2022
code423n4 added a commit that referenced this issue Feb 23, 2022
@atvanguard
Copy link
Collaborator

Duplicate of #128

@atvanguard atvanguard marked this as a duplicate of #128 Feb 24, 2022
@atvanguard atvanguard added the duplicate This issue or pull request already exists label Feb 24, 2022
@moose-code moose-code added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Mar 9, 2022
@CloudEllie CloudEllie removed the duplicate This issue or pull request already exists label Mar 15, 2022
@CloudEllie CloudEllie reopened this Mar 15, 2022
@CloudEllie CloudEllie added the duplicate This issue or pull request already exists label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants