Skip to content
Business logic Audit finding Intermediate

Controller doesn't send treasury funds to the vault's treasury address

The Controller contract sends treasury fees to its own immutable treasury address instead of the treasury address stored in each vault. This prevents vaults from having different treasury addresses and makes the vault's setTreasury function ineffective.

Dug Follow with Ruhum, bin2chen and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/110

Found by

Dug, Ruhum, bin2chen, nobody2018, roguereddwarf

Summary

The Controller contract sends treasury funds to its own immutable treasury address instead of sending the funds to the one stored in the respective vault contract.

Vulnerability Detail

Each vault has a treasury address that is assigned on deployment which can also be updated through the factory contract:

SOL
    constructor(
        // ...
        address _treasury
    ) SemiFungibleVault(IERC20(_assetAddress), _name, _symbol, _tokenURI) {
        // ...
        treasury = _treasury;
        whitelistedAddresses[_treasury] = true;
    }

    function setTreasury(address _treasury) public onlyFactory {
        if (_treasury == address(0)) revert AddressZero();
        treasury = _treasury;
    }

But, the Controller, responsible for sending the fees to the treasury, uses the immutable treasury address that it was initialized with:

SOL
    constructor(
        // ...
        address _treasury
    ) {
        // ...
        treasury = _treasury;
    }

    // @audit just one example. Search for `treasury` in the Controller contract to find the others
    function triggerEndEpoch(uint256 _marketId, uint256 _epochId) public {
        // ...
        
        // send premium fees to treasury and remaining TVL to collateral vault
        premiumVault.sendTokens(_epochId, premiumFee, treasury);
        // strike price reached so collateral is entitled to collateralTVLAfterFee
        premiumVault.sendTokens(
            _epochId,
            premiumTVLAfterFee,
            address(collateralVault)
        );

        // ...
    }

Impact

It's not possible to have different treasury addresses for different vaults. It's also not possible to update the treasury address of a vault although it has a function to do that. Funds will always be sent to the address the Controller was initialized with.

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/VaultV2.sol#L79 https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/VaultV2.sol#L265-L268

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L186 https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L40

Tool used

Manual Review

Recommendation

The Controller should query the Vault to get the correct treasury address, e.g.:

SOL
collateralVault.sendTokens(_epochId, collateralFee, collateralVault.treasury());

Discussion

3xHarry

will use one location for the treasury address which will be on the factory.

3xHarry

fixed in https://github.com/Y2K-Finance/Earthquake/pull/137

IAm0x52

Needs additional changes. Controller still sends to it's immutable address and not treasury address on factory

IAm0x52

Fix looks good. Controller has been updated to use treasury address from factory

jacksanford1

Note: 0x52 is referring to this specific commit in the last message:

https://github.com/Y2K-Finance/Earthquake/pull/137/commits/272199687465252d1da8cb1af624e90c12315953

The original report as published on Sherlock, by Dug. 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

The Controller uses its own immutable treasury address instead of querying the vault's treasury address.

Impact

It is not possible to have different treasury addresses for different vaults, and updating a vault's treasury address has no effect; funds always go to the Controller's initial treasury address.

What the attacker needed

None

The fix

The Controller should query the vault for its treasury address when sending fees, or use a single treasury address from the factory as later 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.

Each vault has a treasury address where fees go, and this address can be changed. But the Controller, which actually sends the fees, uses a fixed address set when it was created. So fees always go to that fixed address, ignoring any changes made in the vault.

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 Dug

View all

7 more disclosed reports, best first.

More from Y2K

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.