Skip to content
Smart contracts Audit finding Advanced

Attacker can steal 100% of users deposits

A first-depositor inflation flaw in a yield portfolio token lets an attacker mint a tiny share balance and then donate tokens so that later depositors receive zero shares. The attacker can then withdraw the donated funds together with other users' deposits, taking their money.

0xEkko Follow with 0xFlare, AshishLac and 19 others

Originally disclosed on Sherlock

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

This issue has been acknowledged by the team but won't be fixed at this time.

Found by

0xEkko, 0xFlare, AshishLac, BobbyAudit, EgisSecurity, HeckerTrieuTien, LeFy, Olugbenga-ayo, Phaethon, X0sauce, alicrali33, anonymousjoe, araj, blockace, iam0ti, ivanalexandur, magiccentaur, s4bot3ur, v10g1, veerendravamshi, xiaoming90, zxriptor

Summary

I want to specify this can happen with any tokens I have just given the example with 1e6.

If an attacker donates a very large amount in the contract, then on the first deposit the contract calls _subDepositRewardsPoolCheck, which will deposit the amount that the address holds of the token into the pool, making totalVirtual inflated.

However the first depositor can also be the attacker, the logic of the contract is that if realTotal is 0 we mint 1:1, if the attacker calls deposit with 1000 wei( because we need to get around the amountSP calculation in pool.deposit which will yield a 1 wei deposit out of the 1000 wei), then the attacker can set realTotal to 1 wei

How the attack will happen:

1.Attacker calls deposit 1st, he sets realTotal = 1 wei, then he sees user1 want to donates 10e6, he front-runs him and transfers 10e6) to the contract, the contract assumes this is a reward and deposits it into the pool, which will make virtualTotal:10e3+ 1, and realTotal:1 wei

  1. User2 deposits, he gets to the part where erc20 has to be minted to him:

out := div(mul(virtualAmount, realTotal), totalVirtual)

Now virtualAmount is 10e3, realTotal is 1 wei, and totalVirtual is 10e3 + 1, which makes ( 10e3 * 1) / 10e3 = 0

What happens if out = zero in _mintAfterTotalChanged: if (realAmount == 0) { return; }

We return to the deposit but we do NOT revert

Now attacker calls withdraw the formula inside burn is: realTotal * (amount / totalVirtual), so realTotal is 1, amount = 20e6 , totalVirtual is 20e6: (1 * (20e6/20e6) = 1, the attacker withdraws his initial donation + the user transfer.

The attacker can donate on every transfer users make so their deposits mint 0 erc20 and with his 1 erc20 he can steal all of the users deposits

Root Cause

Inside _mintAfterTotalChanged the contract should revert if realAmount == 0

Internal Pre-conditions

Attacker needs to be first to call deposit with 1000 wei

External Pre-conditions

Attack Path

Described

Impact

Attacker can steal 100% of users deposits, Impact: HIGH

PoC

Mitigation

Revert inside _mintAfterTotalChanged instead of returning:

Solidity

  uint256 realAmount = _fromVirtualAfterTotalChangedForMint(virtualAmount, index);
        if (realAmount == 0) {
            revert;
        }
        return MultiToken._mint(account, realAmount, index);

Add a minAmountIn deposit

Implement a new reward system which tracks how much rewards did the contract actually receive from the pool

If you are worried about dust amounts implement a onlyOwner function which sweeps any amounts from contract into the pool, that way the owner can foresee if direct transfers will hurt the system in any way

The original report as published on Sherlock, by 0xEkko. 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 minting routine silently returns instead of reverting when the computed share amount rounds to zero, so a deposit succeeds while crediting no shares.

Impact

The attacker can steal 100% of users' deposits, and the team has acknowledged the issue but will not fix it at this time.

What the attacker needed

Attacker deposits first with a tiny amount; attacker front-runs victim deposits; victim deposits after the donation

The fix

The mint routine should revert when the computed amount is zero, a minimum deposit should be enforced, and rewards should be tracked from actual pool receipts rather than raw transfers.

How it was found

  1. The attacker is the first to call deposit with a tiny amount, setting the real total to one wei.
  2. The attacker front-runs a victim's deposit by transferring a large amount directly to the contract, which is treated as a reward and inflates the virtual total.
  3. The victim deposits, but the share calculation rounds down to zero and the mint function returns without reverting.
  4. The attacker withdraws and receives the donated amount plus the victim's deposit.

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 hands out shares when people put tokens in, and the share maths depends on how many tokens the vault thinks it holds. If an attacker is the very first depositor and then sends extra tokens straight to the vault, the maths rounds later deposits down to zero shares, so victims get nothing while the attacker's single share is worth everything. The attacker then withdraws and walks away with the victims' tokens.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 0xEkko

View all

10 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.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.