Skip to content
Access control Audit finding Intermediate

Migrator contract lacks sufficient permissions over vault positions

The vault's migrate function only calls the migrator contract without granting it permission over the vault's shares, so the migrator cannot liquidate or transfer the position. This prevents the intended full migration of funds and positions.

hickuphh3 Follow with ABA, jkoppel and 3 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-fair-funding-judging/issues/91

Found by

hickuphh3, ABA, jkoppel, Ruhum, 0x52, minhtrng

Summary

The migrator contract lacks sufficient permissions over vault shares to successfully perform migration.

Vulnerability Detail

Since vault potentially holds an Alchemix position over a long time during which changes at Alchemix could happen, the migration_admin has complete control over the vault and its position after giving depositors a 30 day window to liquidate (or transfer with a flashloan) their position if they're not comfortable with the migration.

We see that all that migrate() does is to trigger the migrate() function on the migration contract. However, no permissions over the vault's shares were given to the migration contract to enable it to say, liquidate to underlying or yield tokens. It also goes against what was intended, that is, "complete control over the vault and its position".

VYPER
@external
def migrate():
    """
    @notice
        Calls migrate function on the set migrator contract.
        This is just in case there are severe changes in Alchemix that
        require a full migration of the existing position.
    """
    assert self.migration_active <= block.timestamp, "migration not active"
    assert self.migration_executed == False, "migration already executed"
    self.migration_executed = True
    Migrator(self.migrator).migrate()

Impact

Funds / positions cannot be successfully migrated due to lacking permissions.

Code Snippet

https://github.com/sherlock-audit/2023-02-fair-funding/blob/main/fair-funding/contracts/Vault.vy#L545-L556

Tool used

Manual Review

Recommendation

In addition to invoking the migrate() function, consider calling approveWithdraw() on the migrator contract for all of the vault's shares. https://alchemix-finance.gitbook.io/v2/docs/alchemistv2#approvewithdraw

Also consider using raw_call() for this function call because the current alchemist possibly reverts, bricking the migration process entirely.

Discussion

Unstoppable-DeFi

This is correct, a delegateCall should have been used.

Will fix.

Unstoppable-DeFi

https://github.com/Unstoppable-DeFi/fair-funding/pull/6

HickupHH3

Fix looks good - raw_call used to perform delegatecall on the migrator contract, which can only be set by the migration admin.

The original report as published on Sherlock, by hickuphh3. 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 vault did not approve the migrator contract to withdraw its shares before calling migrate, and used a direct call instead of a delegatecall.

Impact

Funds and positions cannot be successfully migrated because the migrator lacks the necessary permissions.

What the attacker needed

Migration admin triggers migrate; migration window active

The fix

The vault should approve the migrator for all its shares and use a raw call to perform a delegatecall to the migrator, which was fixed in a pull request.

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' funds and can be upgraded by calling a separate migrator contract. The vault never gave the migrator permission to move the vault's shares, so the migrator cannot actually move the funds during an upgrade.

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 hickuphh3

View all

43 more disclosed reports, best first.

More from Fair Funding by Alchemix & Unstoppable

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.