Skip to content
Access control Audit finding Intermediate

A malicious/compromised Registry or Factory admin can drain all the funds from the Vault contracts

The Vault contract lets any address listed as a market in the Registry borrow tokens and send them to any address, with no cap on the amount. A malicious or compromised Registry or Factory admin could register a market and drain all funds held in the Vault.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

https://github.com/code-423n4/2022-01-insure/blob/19d1a7819fe7ce795e6d4814e7ddf8b8e1323df3/contracts/Vault.sol#L52-L58

modifier onlyMarket() {
    require(
        IRegistry(registry).isListed(msg.sender),
        "ERROR_ONLY_MARKET"
    );
    _;
}

https://github.com/code-423n4/2022-01-insure/blob/19d1a7819fe7ce795e6d4814e7ddf8b8e1323df3/contracts/Vault.sol#L201-L206

function borrowValue(uint256 _amount, address _to) external onlyMarket override {
    debts[msg.sender] += _amount;
    totalDebt += _amount;

    IERC20(token).safeTransfer(_to, _amount);
}

The current design/implementation allows a market address (registered on the registry) to call Vault#borrowValue() and transfer tokens to an arbitrary address.

Proof of Concept

See the PoC section on [WP-H24].

Recommendation

  1. Consider adding constrains (eg. timelock) to Registry#supportMarket().
  2. Consdier adding constrains (upper bound for each pool, and index pool for example) to Vault#borrowValue().

oishun1112 (Insure) acknowledged and disagreed with severity:

Ownership has to be stolen to drain funds using this method and we assume ownership control driven safely, so we don’t treat this as issue

0xean (judge) commented:

Agree with warden that the privilege addresses should not be able to use approvals in a way that rugs users funds.

Based on the fact that we have seen many rug pulls in the space based on compromised “owner” keys, this is a valid attack path. 3 — High: Assets can be stolen/lost/compromised directly (or indirectly if there is a valid attack path that does not have hand-wavy hypotheticals).

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

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

What the attacker needed

Control of Registry or Factory admin key

The fix

The recommendation was to add constraints such as a timelock on supportMarket and an upper bound on borrowValue; the text does not say whether this was implemented.

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.

A vault holds users' tokens. It trusts a list kept by another contract (the Registry) to decide who may take tokens out. If someone can add an entry to that list, they can take everything, because there is no limit on how much they can withdraw.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by WatchPug

View all

197 more disclosed reports, best first.

More from InsureDAO contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.