Skip to content
Business logic Audit finding Intermediate

No slippage control

The deposit function in PortfolioToken lacks slippage controls, so users may receive fewer portfolio tokens than expected when the underlying pool is imbalanced. An attacker could exploit this by manipulating the pool balance before a victim's deposit, causing the victim to suffer a loss.

0xDemon Follow with 0xloophole, BobbyAudit and 11 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-07-allbridge-core-yield-judging/issues/241

Found by

0xDemon, 0xloophole, BobbyAudit, EgisSecurity, Emine, Hurricane, Mishkat6451, MysteryAuditor, WillyCode20, X0sauce, alicrali33, omeiza, veerendravamshi, xiaoming90

Summary

Root Cause

Internal Pre-conditions

External Pre-conditions

Attack Path

It was observed that the PortfolioToken.deposit() function does not have slippage controls.

https://github.com/sherlock-audit/2025-07-allbridge-core-yield/blob/main/core-auto-evm-contracts/contracts/PortfolioToken.sol#L33

Solidity
File: PortfolioToken.sol
28:     /**
29:      * @dev Deposit tokens into the pool.
30:      * @param amount The amount of tokens to deposit.
31:      * @param index The index of the pool to deposit to.
32:      */
33:     function deposit(uint amount, uint index) external {

As a result, during deposits, users will be subjected to slippage, leading to them receiving fewer portfolio tokens/real amount than expected.

The pool of the AllBridge protocol uses a formula similar to Curve's StableSwap.

The following Python script is directly translated from the PoolUtils.getD() function. The script will compute the number of pool shares minted based on the current reserve (X and Y, USDT and vUSD) of the pool.

Python
import math

def compute_D(x, y, a):
    xy = x * y
    p1 = a * xy * (x + y)
    p2 = (xy * ((a << 2) - 1)) // 3
    p3 = math.sqrt(p1 * p1 + p2 * p2 * p2)
    
    if p3 > p1:
        d_ = math.pow(p3 - p1, 1/3)
        d_ = math.pow(p1 + p3, 1/3) - d_
    else:
        d_ = math.pow(p1 + p3, 1/3) + math.pow(p1 - p3, 1/3)
    
    return d_ * 2

def simulate_deposit(x, y, a, deposit):
    old_D = compute_D(x, y, a)
    total = x + y
    add_x = deposit * x // total
    add_y = deposit * y // total
    new_D = compute_D(x + add_x, y + add_y, a)
    lp_minted = new_D - old_D
    return lp_minted, old_D, new_D


# Test parameters
a = 10
deposit = 100

# Scenario 1: Balanced
x1, y1 = 1000, 1000
lp_minted_1, D0_1, D1_1 = simulate_deposit(x1, y1, a, deposit)

# Scenario 2: Imbalanced
x2, y2 = 1500, 500
lp_minted_2, D0_2, D1_2 = simulate_deposit(x2, y2, a, deposit)

# Scenario 3: More Imbalanced
x3, y3 = 1800, 200
lp_minted_3, D0_3, D1_3 = simulate_deposit(x3, y3, a, deposit)

print("Scenario 1 (Balanced):")
print(f"  LP minted: {lp_minted_1}")
print(f"  D before: {D0_1}")
print(f"  D after: {D1_1}\n")

print("Scenario 2 (Imbalanced):")
print(f"  LP minted: {lp_minted_2}")
print(f"  D before: {D0_2}")
print(f"  D after: {D1_2}\n")

print("Scenario 3 (More Imbalanced):")
print(f"  LP minted: {lp_minted_3}")
print(f"  D before: {D0_3}")
print(f"  D after: {D1_3}")

Note that for StableSwap formula or implementation:

  • If the pool is balanced, depositing 100 USDT will mint around 100 pool shares (e.g., 99.99999999999818)
  • However, when the pool is imbalanced (as shown in the 3rd scenario), depositing 100 USDT will only mint 96 pool shares.
Python
Scenario 1 (Balanced):
  LP minted: 99.99999999999818
  D before: 2000.0
  D after: 2099.999999999998

Scenario 2 (Imbalanced):
  LP minted: 99.22424784315808
  D before: 1984.4849568631507
  D after: 2083.709204706309

Scenario 3 (More Imbalanced):
  LP minted: 96.21928342445199
  D before: 1924.3856684890352
  D after: 2020.6049519134872

This proves that the amount of pool shares minted to the PortfolioToken contract is dependent on the current state/reserve of the pool when the transaction is executed, and is subject to slippage.

Assume that the share price is 1:1 in the PortfolioToken contract. One (1) pool share/virtual token will mint one (1) portfolio token/real token.

Alice deposits 100 USDT to the PortfolioToken contract, and expects that 99.99999 portfolio tokens/real tokens will be minted to her. However, due to the slippage, she only received 96 portfolio tokens/real tokens in return, resulting in a loss to Alice. If Alice redeems his 96 portfolio, she will receive only around 96 USDT back.

Note that the pool is not always balanced. The pool can become imbalanced for many reasons. For instance, if there is a large cross-chain transfer that swaps a large number of vUSD to USDT OR swaps a large number of USDT to vUSD, the pool will become imbalanced.

Note that it is expected that the imbalance pool will be arbitrage back to a balanced pool. However, an important point is that arbitrage does not occur immediately, as it takes time for the bots to notice the imbalance. If Alice's deposit transaction is executed immediately after a large swap/cross-chain transfer, she will suffer significant slippage due to imbalances in the pool.

Impact

Loss of funds for the victims, as demonstrated in the report.

PoC

No response

Mitigation

No response

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/allbridge-public/core-auto-evm-contracts/pull/1

The original report as published on Sherlock, by 0xDemon. 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 deposit function does not allow users to specify a minimum amount of tokens to receive, so they are exposed to slippage when the pool is imbalanced.

Impact

Users could receive fewer portfolio tokens than expected, resulting in a loss of funds, especially if the pool is imbalanced at the time of deposit.

What the attacker needed

Pool is imbalanced; user deposits without slippage protection

The fix

The protocol team fixed this issue 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.

When you deposit money into a pool, you get tokens representing your share. If the pool's balance is off, you might get fewer tokens than you paid for. This report says the deposit function doesn't let you set a minimum number of tokens you'll accept, so you can lose money if the pool is unbalanced.

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 0xDemon

View all

8 more disclosed reports, best first.

More from Allbridge Core Yield

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.