Skip to content
Business logic Audit finding Intermediate

MarginAccountHelper will be bricked if registry.marginAccount or insuranceFund ever change

The MarginAccountHelper contract updates its references to marginAccount and insuranceFund via syncDeps but does not update token approvals to the new contracts. If those addresses ever change, all transactions through the helper would revert, bricking the contract.

0x52 Follow with crimson-rat-reach

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-04-hubble-exchange-judging/issues/170

Found by

0x52, crimson-rat-reach

Summary

MarginAccountHelper#syncDeps causes the contract to refresh it's references to both marginAccount and insuranceFund. The issue is that approvals are never made to the new contracts rendering them useless.

Vulnerability Detail

MarginAccountHelper.sol#L82-L87

function syncDeps(address _registry) public onlyGovernance {
    IRegistry registry = IRegistry(_registry);
    vusd = IVUSD(registry.vusd());
    marginAccount = IMarginAccount(registry.marginAccount());
    insuranceFund = IInsuranceFund(registry.insuranceFund());
}

When syncDeps is called the marginAccount and insuranceFund references are updated. All transactions require approvals to one of those two contract. Since no new approvals are made, the contract will become bricked and all transactions will revert.

Impact

Contract will become bricked and all contracts that are integrated or depend on it will also be bricked

Code Snippet

MarginAccountHelper.sol#L82-L87

Tool used

Manual Review

Recommendation

Remove approvals to old contracts before changing and approve new contracts after

Discussion

asquare08

Valid issue but we will be using syncDeps mainly during the deployment. Later on, since both marginAccount and insuranceFund are upgradeable contracts, their address won't change.

The original report as published on Sherlock, by 0x52. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the syncDeps function updates contract references without revoking old approvals and granting new ones, so the helper lacks the necessary allowances to operate with the new contracts.

Impact

If the marginAccount or insuranceFund addresses change, the helper contract becomes unusable and any contracts depending on it are also bricked.

What the attacker needed

SyncDeps is called with new marginAccount or insuranceFund…

The fix

The recommendation is to remove approvals to the old contracts before changing the references and then approve the new contracts after.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This is a smart contract that helps users interact with two other contracts. It needs permission (approvals) to move tokens on behalf of users. If the helper starts pointing to new contracts but doesn't get new permissions, it can't do its job and everything breaks.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0x52

View all

211 more disclosed reports, best first.

More from Hubble Exchange

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.