`totalBPTSupply` will be excessively inflated
The emergency settlement check for a boosted Balancer leverage vault used the pool's total token supply instead of its virtual supply, so the computed supply figure was vastly inflated. As a result the emergency settlement threshold was far too high, the check always reverted, and keepers would wrongly conclude no emergency settlement was needed.
thekmj Follow with xiaoming90
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-12-notional-judging/issues/11
Found by
thekmj, xiaoming90
Summary
The totalBPTSupply will be excessively inflated as totalSupply was used instead of virtualSupply. This might cause a boosted balancer leverage vault not to be emergency settled in a timely manner and holds too large of a share of the liquidity within the pool, thus having problems exiting its position.
Vulnerability Detail
Balancer's Boosted Pool uses Phantom BPT where all pool tokens are minted at the time of pool creation and are held by the pool itself. Therefore, virtualSupply should be used instead of totalSupply to determine the amount of BPT supply in circulation.
However, within the Boosted3TokenAuraVault.getEmergencySettlementBPTAmount function, the totalBPTSupply at Line 169 is derived from the totalSupply instead of the virtualSupply. As a result, totalBPTSupply will be excessively inflated (2**(111)).
File: Boosted3TokenAuraVault.sol
165: function getEmergencySettlementBPTAmount(uint256 maturity) external view returns (uint256 bptToSettle) {
166: Boosted3TokenAuraStrategyContext memory context = _strategyContext();
167: bptToSettle = context.baseStrategy._getEmergencySettlementParams({
168: maturity: maturity,
169: totalBPTSupply: IERC20(context.poolContext.basePool.basePool.pool).totalSupply()
170: });
171: }
As a result, the emergencyBPTWithdrawThreshold threshold will be extremely high. As such, the condition at Line 97 will always be evaluated as true and result in a revert.
File: SettlementUtils.sol
86: function _getEmergencySettlementParams(
87: StrategyContext memory strategyContext,
88: uint256 maturity,
89: uint256 totalBPTSupply
90: ) internal view returns(uint256 bptToSettle) {
91: StrategyVaultSettings memory settings = strategyContext.vaultSettings;
92: StrategyVaultState memory state = strategyContext.vaultState;
93:
94: // Not in settlement window, check if BPT held is greater than maxBalancerPoolShare * total BPT supply
95: uint256 emergencyBPTWithdrawThreshold = settings._bptThreshold(totalBPTSupply);
96:
97: if (strategyContext.vaultState.totalBPTHeld <= emergencyBPTWithdrawThreshold)
98: revert Errors.InvalidEmergencySettlement();
File: BalancerVaultStorage.sol
52: function _bptThreshold(StrategyVaultSettings memory strategyVaultSettings, uint256 totalBPTSupply)
53: internal pure returns (uint256) {
54: return (totalBPTSupply * strategyVaultSettings.maxBalancerPoolShare) / BalancerConstants.VAULT_PERCENT_BASIS;
55: }
Impact
Anyone (e.g. off-chain keeper or bot) that relies on the SettlementUtils.getEmergencySettlementBPTAmount to determine if an emergency settlement is needed would be affected. The caller will presume that since the function reverts, emergency settlement is not required and the BPT threshold is still within the healthy level. The caller will wrongly decided not to perform an emergency settlement on a vault that has already exceeded the BPT threshold.
If a boosted balancer leverage vault is not emergency settled in a timely manner and holds too large of a share of the liquidity within the pool, it will have problems exiting its position.
Code Snippet
Tool used
Manual Review
Recommendation
Update the function to compute the totalBPTSupply from the virtual supply.
function getEmergencySettlementBPTAmount(uint256 maturity) external view returns (uint256 bptToSettle) {
Boosted3TokenAuraStrategyContext memory context = _strategyContext();
bptToSettle = context.baseStrategy._getEmergencySettlementParams({
maturity: maturity,
- totalBPTSupply: IERC20(context.poolContext.basePool.basePool.pool).totalSupply()
+ totalBPTSupply: context.poolContext._getVirtualSupply(context.oracleContext)
});
}
Discussion
weitianjie2000
valid, will fix
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 code read the pool's total token supply rather than the virtual supply that reflects tokens actually in circulation, inflating the threshold used in the emergency settlement check.
Impact
A keeper or bot relying on the function would see a revert and wrongly skip an emergency settlement, so a vault holding too large a share of pool liquidity could struggle to exit its position.
What the attacker needed
Vault exceeds its BPT share threshold; keeper relies on the view function
The fix
The function should compute the supply from the virtual supply instead of the pool's total supply; the report notes the team said it would fix this.
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 holds a share of a shared liquidity pool and must exit early if its share grows too large. To decide this, the code compares the vault's holding against a percentage of the pool's token supply. It used the wrong supply number, which was far too big, so the comparison always said 'you are fine' and the safety exit never triggered.
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.