Skip to content
Business logic Audit finding Intermediate

ShortLongSpell#openPosition uses the wrong balanceOf when determining how much collateral to put

The ShortLongSpell#openPosition function incorrectly uses the balance of the uToken instead of the vault token when determining collateral to deposit, leaving vault tokens in the contract. An attacker could steal these leftover vault tokens.

0x52 Follow

Originally disclosed on Sherlock

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

Found by

0x52

Summary

The _doPutCollateral subcall in ShortLongSpell#openPosition uses the balance of the uToken rather than the vault resulting in the vault tokens being left in the contract which will be stolen.

Vulnerability Detail

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

    address vault = strategies[param.strategyId].vault;
    _doPutCollateral(
        vault,
        IERC20Upgradeable(ISoftVault(vault).uToken()).balanceOf(
            address(this)
        )
    );

When putting the collateral the contract is putting vault but it uses the balance of the uToken instead of the balance of the vault.

Impact

Vault tokens will be left in contract and stolen

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

Use the balanceOf vault rather than vault.uToken

Discussion

sleepriverfish

Escalate for 10 USDC

In #Blueberry Update, despite the successful escalation of the issue, no reward was granted for the heightened severity and impact of the vulnerability. However, in #Blueberry Update2, a reward was offered specifically for the detection and reporting of a similar vulnerability. https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/116

sherlock-admin

Escalate for 10 USDC

In #Blueberry Update, despite the successful escalation of the issue, no reward was granted for the heightened severity and impact of the vulnerability. However, in #Blueberry Update2, a reward was offered specifically for the detection and reporting of a similar vulnerability. https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/116

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

IAm0x52

This issue has been escalated in the first contest and should be valid in both

hrishibhat

Escalation accepted

This is a valid issue, and necessary decisions have been taken in the respective issue from the previous contest.

sherlock-admin

Escalation accepted

This is a valid issue, and necessary decisions have been taken in the respective issue from the previous contest.

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

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 balance of the uToken instead of the vault token when calculating how much collateral to deposit.

Impact

Vault tokens will be left in the contract and could be stolen by an attacker.

What the attacker needed

None

The fix

The contract should use the balance of the vault token rather than the uToken when determining collateral.

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 checks the wrong token balance. The contract holds two types of tokens: vault tokens and uTokens. When it tries to deposit collateral, it looks at the uToken balance instead of the vault token balance, so it deposits the wrong amount and leaves vault tokens stuck in the contract. Anyone can then take those leftover tokens.

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.