On September 4, 2026, Notional Finance was attacked, resulting in a loss of approximately $1.73 million. All it took was one unsafe cast to exploit it.
Context
Before looking at the exploit, it helps to understand four concepts used throughout the analysis:
- fCash: Notional uses fCash to represent cash claims and liabilities at a specific maturity. A cash receiver holds a positive fCash balance, while a cash payer holds a negative balance.
Receiver: +X fCash
Payer: -X fCash
-
Portfolio: Notional records these positions in a Portfolio. Each position contains information such as the currency, maturity, asset type, and balance.
-
Free collateral: Notional uses a free collateral check to determine whether an account can safely create or modify a position. The protocol aggregates an account’s assets and liabilities and converts them into a common value for the risk calculation.
Root Cause
The core issue behind the exploit lives in ExchangeRate._convertToETH():
function _convertToETH(
Rate memory er,
uint256 baseDecimals,
int256 balance
) internal view returns (int256) {
uint256 rate = _fetchExchangeRate(er, true);
uint128 absBalance = uint128(balance.abs());
int256 result = int256(
SafeCast.toUint128(rate
.mul(absBalance)
.mul(baseDecimals)
.div(Common.DECIMALS)
.div(er.rateDecimals)
)
);
return balance > 0 ? result : result.neg();
}
In this exploit, the attacker first created two liquidity positions with the same payer, with amounts of 1 and uint128.max. Adding the two liabilities together produces exactly 2^128. Payments by the payer are recorded as negative values in the risk calculation.
The liability reaches exactly -2^128, which is representable as an int256. _convertToETH() takes its absolute value, producing 2^128, and then narrows that value to uint128. Since 2^128 is outside the range of uint128, the conversion truncates the value to 0. The mintfCashPair function has a check requiring the payer’s free collateral to be greater than or equal to zero. Because the overflow makes the result 0, that check passes — allowing an account without sufficient assets to cover its liabilities to still establish the position.
Step-by-Step Analysis
-
In the transaction (
0xe1589a19fe742f0d553889214abade69551fe944acffac014c28cc07b325d60a), the attacker deployed multiple contracts and calledsetApprovalForAll. The attacker also fetched the maturity dates of two cash markets in advance and precalculated the values of the threeAssetIds that would be used in the next operations.You can inspect the complete execution trace here: Phalcon Trace
-
After deploying the contracts, the attacker called
safeTransferFromon the ERC1155 Trade contract to mint fCash with an amount of 1. The corresponding bond asset had acashGroupIdof 2 and a timestamp of 1,788,480,000. This call tomintfCashinternally invokesupsertAsset(), which updates the liability and expected income for both the attacker’s address and the receiving address. -
Once the pair is minted, the portfolio immediately calls the
freeCollateralfunction on the attacker’s contract. The value of the first mint (1) converts to ETH at the current exchange rate precision as effectively zero after rounding down, so the check passes. -
The attacker repeats step 2, but this time mints an amount of
uint128.max. The corresponding bond asset again has acashGroupIdof 2, but a different timestamp of 1,796,256,000. Crucially, the attacker used two different maturity dates for the bond assets. This prevents the two notional amounts from being aggregated into the same portfolio entry. If they shared the same maturity, the amounts would be added directly during portfolio aggregation, causing the SafeMath addition to revert:
} else if (!isCounterparty) {
// If the asset types match, then just aggregate the notional amounts.
portfolio[index].notional = notional.add(asset.notional); // <------
- After step 4,
mintfCashinternally callsfreeCollateralagain to calculate the net collateral position and confirm it’s greater than or equal to 0:
(int256 fc, /* int256[] memory */, /* int256[] memory */) = freeCollateral(payer);
require(fc >= 0, "5");
freeCollateral calls freeCollateralView, which calls _freeCollateral, which calls getRequirements in the RiskFramework contract. This function sums the total liability from the two mints for the payer’s address:
for (uint256 j; j < ladders[i].cashLadder.length; j++) {
int256 netfCash = ladders[i].cashLadder[j];
if (netfCash > 0) {
uint32 maturity = initialMaturity + cashGroups[i].maturityLength * uint32(j);
// If netfCash value is positive here then we have to haircut it.
netfCash = _calculateReceiverValue(netfCash, maturity, blockTime, fCashHaircut, fCashMaxHaircut);
}
requirements[i].netfCashValue = requirements[i].netfCashValue.add(netfCash);
}
This produces a final result of -2^128. Inside _freeCollateral, this value is passed on to be converted into ETH:
// inside _freeCollateral():
int256[] memory ethBalances = Escrow().convertBalancesToETH(balances); // <----
convertBalancesToETH loops over each currency’s balance and, for negative amounts, hands them to _convertToETH:
// inside convertBalancesToETH(), for each negative currency balance:
results[i] = ExchangeRate._convertToETH(er, baseDecimals, amounts[i], true); // <----
Looking at _convertToETH, it takes the absolute value of the balance, then force-converts that 256-bit value down to 128 bits. Since the total liability is exactly -2^128, taking the absolute value yields 2^128 exactly and converting that value to a uint128 results in 0:
function _convertToETH(
Rate memory er,
uint256 baseDecimals,
int256 balance,
bool buffer
) internal view returns (int256) {
uint256 rate = _fetchExchangeRate(er, false);
uint128 absBalance = uint128(balance.abs()); // <--------
int256 result = int256(
SafeCast.toUint128(rate
.mul(absBalance)
.mul(buffer ? er.buffer : Common.DECIMALS)
.div(er.rateDecimals)
.div(baseDecimals)
)
);
return balance > 0 ? result : result.neg();
}
This means the protocol wrongly treats the free collateral position as 0 — and therefore healthy — which lets the final check in mintfCash pass.
-
The receiving contract splits its position across two other contracts, triggering two more
safeTransferFromcalls intomintfCashPair. The second of these contracts becomes the payer in that new mint operation, carrying the huge liability obtained in the previous step. The risk calculation treats it as a legitimate claim and passes the collateral check, letting this contract obtain a receiver fCash position that converts into real cash on maturity. -
In a second, profit-taking transaction, the attacker’s holding position from the previous transaction settles, increasing the cash balance of the assets. The attacker then calls the withdraw function to pull out the assets and realize the profit.
The second transaction, where the position is settled and the resulting assets are withdrawn, can be inspected here: Phalcon Trace