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

Collateral assets sent to InsuranceFund by MarginAccount will be frozen #36

Closed
code423n4 opened this issue Feb 21, 2022 · 2 comments
Closed
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/main/contracts/MarginAccount.sol#L377

Vulnerability details

Impact

The assets sent to InsuranceFund by MarginAccount's settleBadDebt will remain frozen there as there are no means implemented to recover them even manually.

Proof of Concept

MarginAccount's settleBadDebt is used to clear an underfunded account.

It's pushing VUSD debt to the insuranceFund and then transferring all the account's collateral there as well:

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/MarginAccount.sol#L377

However, insuranceFund have no ability to manipulate these collateral tokens:

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/InsuranceFund.sol#L39-L85

I.e. deposit/withdrawal, record/settle bad debt is the only functionality implemented.

Even manual retrieval by governance of the collateral tokens sent to the InsuranceFund doesn't seem to be possible.

Recommended Mitigation Steps

Consider adding a manual retrieval function as the first and the simplest step.

Then, as relying on fully manual and off-the-contract process isn't advised, consider an introduction of an asset liquidation function, so the InsuranceFund be able to sell chosen assets (specifying minimum prices to receive from the market as a function argument) to obtain the reserve asset of the VUSD token and then mint VUSD.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Feb 21, 2022
code423n4 added a commit that referenced this issue Feb 21, 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
@moose-code
Copy link
Collaborator

Medium since contracts are upgradeable.

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

3 participants