Skip to content
Business logic Write-up Advanced

Apwine Incorrect Check Of Delegations Bug Fix Review

A missing check in the PT token's transfer hook allowed an attacker to delegate more yield than their actual token balance, because the burn during withdrawal bypassed the delegation check. By repeating deposits, delegations, and withdrawals, an attacker could inflate their delegated amount and later mint and redeem tokens to steal yield from the protocol.

immunefi.com

Published on immunefi.com

In the Web2 world, a simple oversight in the code doesn’t always result in a huge breach of data (of course, sometimes they do). In Web3, the situation is much different.

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The `beforeTokenTransfer` hook skipped its delegation check when the recipient was the zero address (a burn), so withdrawals did not reduce the recorded delegated amount.

What the attacker needed

A fresh account; ability to deposit IBTs; waiting a few periods

How it was found

  1. Deposit IBTs into the FutureVault contract from a fresh account.
  2. Call createFYTDelegationTo from that fresh account, specifying the attacker's address as the receiver, which updates totalDelegationsReceived.
  3. Call the withdraw function to redeem PTs for IBTs; due to the logic error, the check comparing the redeemed amount against the balance plus delegated tokens is not run, so the attacker gets back all deposited PTs while keeping the…
  4. Repeat steps 1–3 multiple times.
  5. Wait a few periods for the inflated delegation to generate yield.
  6. Mint PTs and FYTs and call withdraw to redeem these tokens for IBTs.

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 write-up has not been written yet. The Original tab links to the source.

In this smart contract, users deposit tokens and can delegate the future yield (the interest earned) to someone else. The code that updates delegation amounts was skipped when tokens were burned during withdrawal, so an attacker could pretend to have delegated more than they actually had. They could then collect yield that belonged to others.

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.

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.