Skip to content
Business logic Audit finding Intermediate

ShortLongSpell#openPosition attempts to burn wrong token

The ShortLongSpell#openPosition function attempts to burn the wrong token (vault.uToken instead of vault) when adding to an existing position, causing the function to always revert. This makes the function completely nonfunctional for users adding to their position.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-05-blueberry-judging/issues/30

Found by

0x52

Summary

ShortLongSpell#openPosition attempts to burn vault.uToken when it should be using vault instead. The result is that ShortLongSpell#openPosition will be completely nonfunctional when the user is adding to their position

Vulnerability Detail

https://github.com/sherlock-audit/2023-05-blueberry/blob/main/blueberry-core/contracts/spell/ShortLongSpell.sol#L133-L140

        address burnToken = address(ISoftVault(strategy.vault).uToken());
        if (collSize > 0) {
            if (posCollToken != address(wrapper))
                revert Errors.INCORRECT_COLTOKEN(posCollToken);
            bank.takeCollateral(collSize);
            wrapper.burn(burnToken, collSize);
            _doRefund(burnToken);
        }

We see above that the contract attempts to withdraw vault.uToken from the wrapper.

https://github.com/sherlock-audit/2023-05-blueberry/blob/main/blueberry-core/contracts/spell/ShortLongSpell.sol#L145-L150

    _doPutCollateral(
        vault,
        IERC20Upgradeable(ISoftVault(vault).uToken()).balanceOf(
            address(this)
        )
    );

This is in direct conflict with the collateral that is actually deposited which is vault. This will cause the function to always revert when adding to an existing position.

Impact

ShortLongSpell#openPosition will be completely nonfunctional when the user is adding to their position

Code Snippet

https://github.com/sherlock-audit/2023-05-blueberry/blob/main/blueberry-core/contracts/spell/ShortLongSpell.sol#L111-L151

Tool used

Manual Review

Recommendation

Burn token should be vault rather than vault.uToken

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

The code uses the underlying token (vault.uToken) instead of the vault token itself when burning collateral, which does not match the token that was deposited.

Impact

ShortLongSpell#openPosition will be completely nonfunctional when the user is adding to their position.

What the attacker needed

User has an existing position; user calls openPosition to add collateral

The fix

The burn token should be vault rather than vault.uToken.

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 bug where a function tries to remove the wrong type of token from a user's account. Because the token it tries to remove is not the one actually deposited, the operation always fails, so users cannot add to their existing position.

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 Blueberry Update #3

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.