Skip to content
Business logic Audit finding Advanced

Protected listings checkpoints are not always updated when the total supply changes

The ProtectedListings contract fails to create a new checkpoint whenever the total supply of collection tokens changes, leading to incorrect interest rate calculations. An attacker can exploit this by manipulating the total supply to artificially inflate the utilization rate, causing users to pay higher interest or face liquidation.

IronsideSec Follow with Sentryx, valuevalk and 1 other

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/515

Found by

Ironsidesec, Sentryx, valuevalk, zzykxx

Summary

The protocol doesn't update protected listings checkpoints every time the total supply of collection token changes

Root Cause

The ProtectedListing contract uses a checkpoint system to keep track of the interests to pay. It calculates the current interest rate of a collection based on the utilization rate, which depends, among other factors, on the total supply of collection tokens.

For this system to work correctly everytime the total supply changes a new checkpoint for the collection should be created, but this is not the case as both Locker::deposit() and Locker::redeem(), which mint and burn collection tokens, don't create a new checkpoint in the protected listing contract.

Another case where this happens is the UniswapImplementation::afterSwap() hook, where collection tokens can be burned.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

This is a problem by itself, as users will pay a wrong interest rate, but it can also be taken advantage of to force users to pay a huge amount of interest or get their protected listings liquidated:

  1. Alice creates a new protected listing via ProtectedListings::createListings(). This is the first protected listing of the collection and as such she expects a low interest rate.
  2. Eve, a liquidity provider, flashloans all of the collection tokens currently in the UniswapV4 pool.
  3. Eve calls Locker::redeem() in order to burn all of the flashloaned collection tokens in the exchange for NFTs. This lowers the total supply of collection tokens and increases the utilization rate.
  4. Eve calls Listings::cancelListings() by passing as an emppty array as token ids. This creates a checkpoint for the collection.
  5. Eve calls Locker::deposit() in order to re-deposit the NFT collected during point 3 in exchange for collection tokens.
  6. Eve adds the collection tokens back the UniV4 pool.

This results in Alice having to pay a higher interest rate than expected, which is profitable for Eve, or have her NFT liquidated if the interest rate is so high that the position becomes liquidatable in much less time than she expects.

The worst situation possible is for Alice to create a protected listing by borrowing 1 wei of tokens in a collection that's just been created and whose whole total supply is locked in the UniwapV4 pool. Eve would be able to create a situation where:

  1. The total supply is 1 (Alice's borrowed token)
  2. The amount of listings is 1 (Alice's listing)

which would result in an utilization rate of:

(listingsOfType_ * 1e36 * 10 ** collectionToken.denomination()) / totalSupply

(1 * 1e36 * 10 ** 0) / 1

1e36

Impact

Since the checkpoints are not correctly updated users will pay a wrong interest rate on protected listings no-matter-what. An attacker can abuse this artificially inflate the utilization rate, which is profitable when the attacker is also a liquidity provider in the UniV4 pool.

PoC

No response

Mitigation

Correctly update collection checkpoints whenever the total supply of collection token changes.

The original report as published on Sherlock, by Ironsidesec. 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

Impact

Users will pay a wrong interest rate on protected listings, and an attacker can artificially inflate the utilization rate to force higher interest payments or liquidations, which is profitable if the attacker is also a liquidity provider.

What the attacker needed

Attacker has funds for flashloan; Victim has a protected listing; Attacker is a liquidity provider

The fix

Correctly update collection checkpoints whenever the total supply of collection token changes.

How it was found

  1. Alice creates a protected listing, expecting a low interest rate.
  2. Eve flashloans all collection tokens from the UniswapV4 pool.
  3. Eve calls Locker::redeem() to burn the flashloaned tokens for NFTs, lowering total supply and increasing utilization rate.
  4. Eve calls Listings::cancelListings() with an empty array to create a checkpoint.
  5. Eve calls Locker::deposit() to re-deposit the NFTs for collection tokens.
  6. Eve adds the collection tokens back to the UniV4 pool.

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.

This report is about a smart contract bug where interest rates for protected listings are calculated using a checkpoint system. The checkpoints are not updated when the total supply of tokens changes, so the interest rate can be wrong. An attacker can take advantage of this to make other users pay more interest or get their listings liquidated.

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 IronsideSec

View all

28 more disclosed reports, best first.

More from Flayer

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.