Skip to content
Business logic Audit finding Intermediate

Malicious user can leverage flash loans to claim all coupon rewards

The Pool contract allows anyone to start an auction, which snapshots bond token balances for reward distribution. An attacker can use a flash loan to mint bond tokens, start an auction, distribute rewards, claim all coupons, and then burn the tokens and repay the loan, leaving other holders with no rewards.

0x23r0 Follow with 0x52, 0xNov1ce and 25 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/725

Found by

0x23r0, 0x52, 0xNov1ce, 0xe4669da, AksWarden, BADROBINX, ChainProof, Etherking, InquisitorScythe, Kenn.eth, MysteryAuditor, Nadir_Khan_Sec, OrangeSantra, Pablo, Schnilch, Strapontin, Uddercover, ZoA, aswinraj94, bladeee, copperscrewer, devalinas, farman1094, future, komane007, momentum, moray5554, phoenixv110

Summary

Anyone can call Pool::startAuction, which will deploy a new auction and checkpoint the sharesPerToken by calling BondToken::increaseIndexedAssetPeriod for the holders of bond token, as long as distributionPeriod have passed since the last distribution.

Solidity
    function startAuction() external whenNotPaused {
        require(lastDistribution + distributionPeriod < block.timestamp, DistributionPeriodNotPassed());
        require(lastDistribution + distributionPeriod + auctionPeriod >= block.timestamp, AuctionPeriodPassed());
       ....
        bondToken.increaseIndexedAssetPeriod(sharesPerToken);
        lastDistribution = block.timestamp;
    }

The Pool::distribute function distributes the rewards from the previous auction, so it can only be called after a new auction has started.

Solidity
 function distribute() external whenNotPaused {
        (uint256 currentPeriod,) = bondToken.globalPool();
        require(currentPeriod > 0, AccessDenied());

        uint256 previousPeriod = currentPeriod - 1;
        uint256 couponAmountToDistribute = Auction(auctions[previousPeriod]).totalBuyCouponAmount();

        ....

The Distributor::claim function gets the shares of the user by callingBondToken::getIndexedUserAmount:

Solidity
    function getIndexedUserAmount(address user, uint256 balance, uint256 period) public view returns (uint256) {
        IndexedUserAssets memory userPool = userAssets[user];
        uint256 shares = userPool.indexedAmountShares;

        for (uint256 i = userPool.lastUpdatedPeriod; i < period; i++) {
            shares += (balance * globalPool.previousPoolAmounts[i].sharesPerToken).toBaseUnit(SHARES_DECIMALS);
        }

        return shares;
    }

The function loops through the periods and accounts for all of the shares during the user's last updated one to the current.

The docs state that as long as the user holds during distribution, he should be eligible for the coupon rewards, however this opens up an opportunity for a flash loan attack.

The attacker can leverage this by minting bond tokens and calling startAuction, which will increase the current period and make it greater than the userPool.lastUpdatedPeriod, which makes the Distributor account his shares.

Root Cause

Pool does not have a flashloan protection allowing users to claim all of the coupon rewards

Internal Pre-conditions

None

External Pre-conditions

None

Attack Path

When users claim through the Distributor::claim 1 share == 1 coupon token, which the attacker can leverage by: In one transaction:

  • Takes a flashloan
  • Mints couponAmountToDistribute / sharesPerToken bond tokens
  • Calls startAuction to snapshot his balance
  • Calls distribute to distribute the coupon rewards to the distributor
  • Calls Distributor::claim to claim all of the shares
  • Burn the bond tokens
  • Repays the flashloan

Impact

All of the other holders will be left with no rewards

PoC

No response

Mitigation

Consider not allowing anyone to turn over a period, or apply some kind of snapshot protection

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/Convexity-Research/plaza-evm/pull/162

The original report as published on Sherlock, by 0x23r0. 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 Pool contract lacks any protection against flash loans or snapshot manipulation, allowing a user to acquire tokens just before a reward snapshot and claim rewards without holding them long-term.

Impact

All other holders could be left with no rewards.

What the attacker needed

None

The fix

The protocol team fixed this issue in a pull request.

How it was found

  1. Take a flash loan.
  2. Mint bond tokens equal to the coupon amount divided by shares per token.
  3. Call startAuction to snapshot the balance.
  4. Call distribute to distribute coupon rewards to the distributor.
  5. Call Distributor::claim to claim all shares.
  6. Burn the bond tokens and repay the flash loan.

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 flash loan is a loan that must be borrowed and repaid within the same transaction. The report shows that an attacker can borrow a large amount, use it to buy reward-earning tokens, trigger a reward payout, collect all the rewards, and then sell the tokens back and repay the loan, all in one transaction. This leaves legitimate holders with nothing.

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

View all

23 more disclosed reports, best first.

More from Plaza Finance

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.