NAV calculation inconsistency due to underlying token position in pool configuration
The NAV calculation in PanopticVaultAccountant.sol handles the vault's underlying token balance inconsistently depending on whether the underlying token appears in any pool. This causes economically identical vaults to report different NAV values, potentially leading to incorrect share prices during deposit or withdrawal fulfilment.
Submitted by dhank, also found by kvar
The computeNAV function in PanopticVaultAccountant.sol contains a logical flaw that causes identical vault positions to report different NAV values based on their pool configuration. The issue comes from inconsistent handling of the vault’s underlying token balance when calculating nav.
The problem:
-
When pools contain the underlying token: The underlying token balance is included inpoolExposurecalculations code within the loop, and the per-poolMath.max(poolExposure0 + poolExposure1, 0)is applied to the combined exposure. -
When pools don't contain the underlying token: The underlying token balance is added after all pool calculations are complete and after theMath.max(_, 0)protection has already been applied per pool.
This creates a scenario where the timing of when underlying token balances are included in the NAV calculation determines whether they can offset negative pool exposures or are lost entirely.
// Inside the pool processing loop:
nav += uint256(Math.max(poolExposure0 + poolExposure1, 0)); // Applied per pool
// After loop completion:
if (!skipUnderlying) {
nav += IERC20Partial(underlyingToken).balanceOf(_vault); // Added to already-processed NAV
}
Hence, Vaults with underlying tokens in their pool configuration report lower NAV values than economically identical vaults without such configuration.
Managers while executing fulfillDeposit() or fullfillWithdrawals(), the txn will execute without any reverts. Otherwise, it would have been underflowed here and the calculated share price will be incorrect putting the protocol and users to risk.
Example:
Two vaults with identical economic positions:
- Pool exposure: -150 USDC (net losses from options trading)
- Underlying balance: +50 USDC (cash reserves)
- Expected NAV: max (-150 + 50, 0) = 0 USDC
Vault A (underlying token USDC appears in ETH/USDC pool):
poolExposure = -150 + 50 = -100 USDC (underlying included)
nav += max(-100, 0) = 0
skipUnderlying = true
Final NAV = 0 USDC (Correct by coincidence)
Vault B (underlying token USDC not in ETH/WBTC pool):
poolExposure = -150 USDC (underlying not included)
nav += max(-150, 0) = 0
skipUnderlying = false
nav += 50 USDC (underlying added after)
Final NAV = 50 USDC (Incorrect - should be 0)
Recommended mitigation steps
Put nav calculation outside of the for loop.
{
for loop pools
....
}
bool skipUnderlying = false;
for (uint256 i = 0; i < underlyingTokens.length; i++) {
if (underlyingTokens[i] == underlyingToken) skipUnderlying = true;
}
if (!skipUnderlying) {
totalExposure += int256(IERC20Partial(underlyingToken).balanceOf(_vault));
}
// Apply Math.max to final aggregated exposure
nav = uint256(Math.max(totalExposure, 0));
```
where totalExposure is net poolExposure0 + poolExposure1 for all pools
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 per-pool application of Math.max(_, 0) before adding the underlying token balance means that when the underlying token is not in any pool, its positive balance cannot offset negative pool exposures, whereas when it is in a pool, it is included before the max is applied.
Impact
Vaults with the underlying token in their pool configuration may report a lower NAV than economically identical vaults without it, leading to incorrect share prices during deposit or withdrawal fulfilment and putting the protocol and users at risk.
What the attacker needed
Vault has underlying token balance; underlying token not in any pool
The fix
The NAV calculation should aggregate total exposure across all pools first, then add the underlying token balance if it is not already included, and finally apply Math.max(_, 0) once to the total.
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 vault's net asset value (NAV) is the total value it holds, used to decide how many shares a deposit buys or a withdrawal pays out. The code adds up gains and losses from different pools, but it treats the vault's own cash balance differently depending on whether that cash token is also traded in a pool. As a result, two vaults with the same real value can show different NAVs, which can give users the wrong share price.
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.