Skip to content
Business logic Write-up Advanced

Notional Double Counting Free Collateral Bug Fix Review

A logic error in Notional V2's bitmap portfolio handling caused free collateral to be double-counted when a bitmap currency was changed. An attacker could borrow far more than their actual collateral, potentially draining almost all liquidity from markets.

immunefi.com

Published on immunefi.com

From time to time, we receive reports that are resolved and paid so quickly that we are barely even able to think about writing a bugfix review. That was the case with Notional and the bug that was submitted to them by whitehat 0x60511e57 via Immunefi on January 7th.

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

Likely, the function that enables a bitmap currency failed to clear the previous active currency entry when the bitmap currency was changed, leading to the same asset being counted twice in free collateral calculations.

Impact

An attacker could drain almost all liquidity from markets on all currencies, as demonstrated by draining 26.2 million DAI from the DAI market.

What the attacker needed

Access to Notional V2 contracts; ability to call enableBitmapCurrency and…

The fix

The enableBitmapCurrency function was disabled and then fixed by removing the ability to change a bitmap currency once set.

How it was found

  1. Enable a bitmap portfolio for any currency (e.g., ETH or a dummy currency) by calling enableBitmapCurrency.
  2. Deposit the currency you want double-counted (e.g., DAI) using depositUnderlyingToken.
  3. Call enableBitmapCurrency again, this time setting the deposited currency (DAI) as the bitmap currency.
  4. The bug triggers, causing the system to count the deposited currency twice in free collateral.
  5. Transfer out double the amount of fCash without the system registering debt.
  6. Send the fCash to another account and convert it to the underlying currency via a Notional market.

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.

Notional is a lending platform where you must provide enough collateral to cover what you borrow. A bug made the system think you had twice as much collateral as you really did, so you could borrow and withdraw more money than you were entitled to. This could let someone steal funds from the platform.

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.