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 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
- Enable a bitmap portfolio for any currency (e.g., ETH or a dummy currency) by calling enableBitmapCurrency.
- Deposit the currency you want double-counted (e.g., DAI) using depositUnderlyingToken.
- Call enableBitmapCurrency again, this time setting the deposited currency (DAI) as the bitmap currency.
- The bug triggers, causing the system to count the deposited currency twice in free collateral.
- Transfer out double the amount of fCash without the system registering debt.
- 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.