BNB Chain
Validation gap

ApeBond's $3.6K Loss and How Olympix Would Have Prevented It

Loss
Loss
Exploit date
June 3, 2026

On June 3, 2026, at 17:14 UTC, one transaction on BNB Chain turned a stake of about 1.71 million ABOND into a voting-escrow lock worth about 29.08 million ABOND. The multiplier was exactly 17, and it came from the attacker typing the same pool ID 17 times into ApeBond's migrateToVotingEscrow function. The attacker sold the inflated balance into the ABOND/WBNB pool, repaid a 2 WBNB flash loan, and walked away with 5.7232 WBNB, worth about $3,577 at the time.

The dollar figure is small because ABOND's liquidity was thin. The mechanism is worth studying anyway, since nothing about it depended on the pool's size. The same call against a deeper market would have taken proportionally more, and the flaw sat in a function any staker could reach.

What ApeYieldVault Did

ApeBond runs an on-chain OTC and bonding marketplace, and on BNB Chain its native token is ABOND. Holders can stake ABOND in ApeYieldVault, a contract that runs a set of yield pools, or lock it in ApeBond's VotingEscrow contract for a non-transferable veABOND position that carries governance weight.

migrateToVotingEscrow connected the two. A staker passed in a list of pool IDs, and the vault was supposed to total what that staker had in each pool, withdraw those stakes, and open a single VotingEscrow lock for the combined amount. It's a convenience feature, the kind of function that makes a protocol easier to use and rarely gets the same scrutiny as a swap or a liquidation path.

Two Loops That Disagreed

The verified ApeYieldVault implementation on Sourcify shows exactly how the function worked. It ran two passes over the caller's list. The first pass validated each entry and added up the staked balance:

for (uint16 i = 0; i < _pids.length; i++) {
    uint16 pid = _pids[i];
    require(pid < pools.length, "Pool does not exist");
    Pool storage pool = pools[pid];
    User storage user = users[pid][msg.sender];
    require(user.stakedTokens > 0, "No staked tokens in pool");
    require(pool.inputToken == veToken, "Token mismatch");
    totalStakedAmount += user.stakedTokens;

The first pass only read balances. Nothing in it changed state, so when the same pool ID appeared twice, the second read returned the same balance as the first and the total grew by the full stake again. The require that the caller had a nonzero stake passed on every repeat for the same reason.

The second pass was where the stakes were actually withdrawn and zeroed:

uint256 stakedAmount = user.stakedTokens;
pool.totalStakedTokens -= stakedAmount;
user.stakedTokens = 0;

On the first occurrence of a pool ID, this pass removed the real stake. On every repeat it found a balance of zero and removed nothing. So the two loops reached different answers about the same list. The first said the caller was owed 17 stakes, and the second only took one. The function then trusted the first answer:

veTokenId = IVotingEscrow_LockLogic(votingEscrow).createLockFor(
    totalStakedAmount,
    _lockDuration,
    msg.sender,
    _lockType
);

The VotingEscrow pulled totalStakedAmount of ABOND from the vault. Since only one real stake had been withdrawn, the other 16 copies came out of ABOND the vault was holding for everyone else.

How the Transaction Unfolded

According to an alert from the Real-time DeFiHacks Intelligence feed on X, which quoted the security researcher audit911, a public helper used migrateToVotingEscrow with duplicate pool IDs to inflate one lock and drain ABOND. The transaction's logs fill in the rest.

The attacker's externally owned account called a purpose-built contract, which borrowed 2 WBNB through a flash loan from the Moolah lending contract. It swapped that 2 WBNB for about 1,710,845 ABOND in the ABOND/WBNB pool and deposited the ABOND into pool 0 of ApeYieldVault.

The contract then called migrateToVotingEscrow with pool 0 listed 17 times. The vault emitted 17 Migrate events, all for pool 0. The first carried the full 1,710,845 ABOND stake, and the other 16 carried zero. The VotingEscrow still minted lock 1157 for about 29,084,362 ABOND, which is 17 times the deposit. That gap of about 27,373,518 ABOND came out of the vault's existing holdings.

In the same transaction, the attacker's contract withdrew the full 29,084,362 ABOND from the VotingEscrow and sold it back into the ABOND/WBNB pool for about 7.7232 WBNB. It repaid the 2 WBNB flash loan and sent the remaining 5.7232 WBNB to the attacker's wallet. At CoinGecko's WBNB price of $625.04 for the hour, that's $3,577. Earlier tallies put it between about $3,421 (SlowMist) and $3,591, depending on the price used.

As of November 25, 2026, we couldn't find a post-mortem or public statement from ApeBond about the incident, and no recovery or bounty had been reported.

The Invariant Nobody Wrote Down

The function's comments describe _pids as an "array of pool ids to migrate from (can be a single pool or multiple pools)". The intent was clear: each pool contributes its stake once. That rule lived in the author's head and in the comment, and it never made it into a require.

There were two equally small ways to enforce it. The function could have rejected duplicates up front, for example by requiring the IDs to be strictly increasing. Or it could have computed the total in the same loop that zeroed each balance, so a repeated ID would add nothing. Either change makes the lock amount equal to the tokens actually withdrawn, which is the property the whole migration depended on.

Duplicate entries in a caller-supplied list are a recurring way for accounting to drift from reality. A repeated entry in an exception list was also at the heart of the Lien Finance $542K exploit, where it let an attacker mint bond tokens with no collateral. The lists differ, but in both cases the code assumed uniqueness it never checked.

How Olympix Would Have Caught the Seventeen Repeats

Olympix reads a contract as states, transitions and entry points, and uses the surrounding context to infer the invariants the system relies on. For ApeYieldVault, the natural invariant is conservation: the amount credited to a new VotingEscrow lock should equal the stake removed from the vault's pools, and no user's migration should reduce what the vault holds for other stakers.

Static analysis would have surfaced the signal in migrateToVotingEscrow. The function accumulates a total from a caller-controlled array in a read-only loop, applies the state changes in a separate loop over the same array, and passes the first loop's total to an external call that moves tokens. Nothing ties the two loops together or rules out repeated elements. Static analysis would have flagged that split as a path where the caller's input shapes a token transfer without a uniqueness check in between.

BugPoCer would then have started from the conservation invariant and searched for a sequence that breaks it. The search space is small: stake in one pool, then call migrateToVotingEscrow with that pool listed twice. That two-entry list already credits twice the stake while withdrawing it once. Had the team run it, BugPoCer would have returned that sequence as a counterexample, with the minimal conditions (any nonzero stake, any pool whose input token is ABOND, other stakers' ABOND in the vault) and a generated Forge test showing the lock amount exceeding the withdrawn stake. That would have been the June 3 drain, reproduced in development with 2 entries instead of 17.

Because these checks run at every merge and before each release, a function added for convenience gets the same treatment as the core swap and staking paths. That matters here, since the vulnerable code sat in a migration helper.

A Lesson for Builders

When a function makes two passes over the same input, treat any value computed in the first pass as a claim that the second pass has to confirm. Sum what you actually moved, and require unique IDs whenever an array feeds arithmetic. Then write the invariant as a test: after any migration, the vault's ABOND balance minus the lock should still cover every other staker.

If you want to see how Olympix would map the invariants in your own contracts and return a runnable counterexample when one breaks, book a technical walkthrough.

On-Chain References

Exploit transaction: 0x52e4...01c6

Attacker EOA: 0xE3C6...BF99

Attack contract: 0x7a02...0796

ApeYieldVault (proxy): 0xcfb6...a535

ApeYieldVault implementation: 0xeacf...c3bd

VotingEscrow (proxy): 0xdf1d...01b2

ABOND token: 0x3429...8bed

ABOND/WBNB pool: 0x44aa...c7c0

Moolah flash loan source: 0x8f73...5d8c

See what Olympix finds on your own code

Send us a repo that's already been audited, and we'll run Olympix at the same commit and show you what comes back.