Ultra-low amount of total shares in collateral pool
A missing check in the self-close exit function lets the pool's share supply drop to a tiny non-zero value after the agent redemption correction. An attacker could then exploit rounding errors, such as a donation attack, to distort collateral and slash calculations.
- Disclosed after under an hour
#46071 [SC-Low] Ultra-low amount of total shares in collateral pool
Submitted on May 24th 2025 at 13:29:59 UTC by @Audittens for Audit Comp | Flare | FAssets
- Report ID: #46071
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/flare-foundation/fassets/blob/main/contracts/assetManager/implementation/CollateralPool.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
- Protocol insolvency
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
Using lack of check in the _selfCloseExitTo function it is posssible to reach state of ultra-low (but non-zero) amount of shares in collateral pool, leading to attacks involving incorrect calculations due to rounding.
Vulnerability Details
In the CollaterPool contract assetData.poolTokenSupply and assetData.poolNatBalance represent shares of the pool and balance of the native token, respectively. The following invariant holds across different part of the code: both poolTokenSupply and poolNatBalance should be big enough (greater than MIN_TOKEN_SUPPLY_AFTER_EXIT=MIN_NAT_BALANCE_AFTER_EXIT=1 ether) or be equal to zero. In the _selfCloseExitTo function this invariant maintained as well -- it is checked for the expected updated values:
AssetData memory assetData = _getAssetData();
require(assetData.poolTokenSupply == _tokenShare ||
assetData.poolTokenSupply - _tokenShare >= MIN_TOKEN_SUPPLY_AFTER_EXIT,
"token supply left after exit is too low and non-zero");
uint256 natShare = assetData.poolNatBalance.mulDiv(
_tokenShare, assetData.poolTokenSupply); // poolTokenSupply >= _tokenShare > 0
require(natShare > 0, "amount of sent tokens is too small");
require(assetData.poolNatBalance == natShare ||
assetData.poolNatBalance - natShare >= MIN_NAT_BALANCE_AFTER_EXIT,
"collateral left after exit is too low and non-zero");
Later, in this function there is a special case for the situation when maxRedemptionFromAgent is not big enough to cover requiredFAssets:
uint256 maxAgentRedemption = assetManager.maxRedemptionFromAgent(agentVault);
uint256 requiredFAssets = _getFAssetRequiredToNotSpoilCR(assetData, natShare);
// rare case: if agent has too many low-valued open tickets they can't redeem the requiredFAssets
// in one transaction. In that case we lower/correct the amount of spent tokens and nat share.
if (maxAgentRedemption < requiredFAssets) {
// natShare and _tokenShare decrease!
requiredFAssets = maxAgentRedemption;
natShare = _getNatRequiredToNotSpoilCR(assetData, requiredFAssets);
require(natShare > 0, "amount of sent tokens is too small after agent max redemption correction");
require(assetData.poolNatBalance == natShare ||
assetData.poolNatBalance - natShare >= MIN_NAT_BALANCE_AFTER_EXIT,
"collateral left after exit is too low and non-zero");
// poolNatBalance >= previous natShare > 0
_tokenShare = assetData.poolTokenSupply.mulDiv(natShare, assetData.poolNatBalance);
emit IncompleteSelfCloseExit(_tokenShare, requiredFAssets);
}
As mentioned in the comment it is very important to recheck the updated values of natShare and _tokenShare, as this values are substracted from poolNatBalance and poolTokenSupply, respectively. The check for natShare is present, but the check for _tokenShare is missing.
Impact Details
Because of the mentioned scenario it is possible to reach the state of ultra-low token share. This leads to variety of attacks, e. g., donation attack, errors in roundings during calculations of needed collateral and slashes.
Proof of Concept
Proof of Concept
To reach mentioned situation the attacker needs to fill the redemption queue in a way, such that because of the maxRedeemedTickets = Globals.getSettings().maxRedeemedTickets limit on the number of redemption tickets, the natShare value will be equal to poolNatBalance - 1 ether, while the _tokenShare = assetData.poolTokenSupply.mulDiv(natShare, assetData.poolNatBalance); value will decrease significantly.
To make the scenario more concrete:
- before the call of the
_selfCloseExitTofunctionpoolTokenSupplywas equal to1 etherand thepoolNatBalancewas equal100 ether; - after the mentioned correction of the
natShareand_tokenSharevalues:natShareequals99 ether; _tokenSharewill be corrected to99/100*poolTokenSupply;- in the result the
poolTokenSupplydivided by a factor of one hundred.
Attacker can peform donation (therefore, increase the poolNatBalance value) and repeat the mentioned sequence of calls. To pass checks in lines 325-327 and 331-333, attacker will make calls in a way, such that at the start of the function, _tokenShare equals to poolTokenSupply.
By repeating mentioned attack the poolTokenSupply will decrease as much as it is required.
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 corrected `_tokenShare` value in the agent max-redemption branch is not re-validated against the minimum supply invariant, unlike `natShare`.
What the attacker needed
Ability to fill the redemption queue; ability to call self-close exit; ability to donate to the pool
How it was found
- Fill the redemption queue so the max redeemed tickets limit caps the agent's redemption.
- Call the self-close exit so the correction branch runs and lowers the share amount.
- Ensure the starting share amount equals the total supply to pass the earlier checks.
- Donate to raise the native balance and repeat the sequence to shrink the share supply further.
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 collateral pool tracks ownership with shares, and each share should be worth a sensible amount. The code recalculates how many shares to remove when an agent cannot redeem everything at once, but it never checks that enough shares remain. That leaves the pool with a near-zero number of shares, which makes the maths round badly and can be abused.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.