Skip to content
Business logic Audit finding Intermediate

Incorrect calculation of total available amount in core vault in a certain case when a user redeems from the core vault

When a user who already has a non-cancelable transfer request submits another redeem to the same destination, the contract merges the amount into the existing request without charging a new fee, but the available-amount calculation still subtracts a fee. This makes the reported available amount and lot count lower than reality, potentially showing zero lots when one is actually available.

swarun Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#47033 [SC-Low] Incorrect calculation of total available amount in core vault in a certain case when a user redeems from the core vault

Submitted on Jun 8th 2025 at 08:16:59 UTC by @swarun for Audit Comp | Flare | FAssets

Description

Brief/Intro

When a user who already has a available non cancelable transfer request again then the total available amount returned is incorrect in that case because it again considers the fee which in reality is not charged again.

Vulnerability Details

In the case of non cancelable transfer requests fees is only charged when there is a new request added but if a redeemer whose request has already been added again requests a transfer no fees is applied to it but when total available amount in the core vault is calculated it again takens into account the fee which is incorrect.

Impact Details

It incorrectly charges fees and causes less available amount calculation even when there is certainly enough tokens available.

References

https://github.com/flare-foundation/fassets/blob/fc727ee70a6d36a3d8dec81892d76d01bb22e7f1/contracts/assetManager/library/CoreVault.sol#L220 https://github.com/flare-foundation/fassets/blob/fc727ee70a6d36a3d8dec81892d76d01bb22e7f1/contracts/assetManager/library/CoreVault.sol#L270

Proof of Concept

Proof of Concept

  1. Suppose the user has already called redeem from core vault therefore it will have a transfer request in nonCancelableTransferRequests array
Solidity
 uint256[] private nonCancelableTransferRequests;
  1. Now suppose a user again calls redeem from core vault with the same destination address so the following calculation for the available amount will be done
Solidity
function getCoreVaultAvailableAmount()
        internal view
        returns (uint256 _immediatelyAvailableUBA, uint256 _totalAvailableUBA)
    {
        State storage state = getState();
        uint256 availableFunds = state.coreVaultManager.availableFunds();
        uint256 escrowedFunds = state.coreVaultManager.escrowedFunds();
        // account for fee for one more request, because this much must remain available on any transfer
        uint256 requestedAmountWithFee =
            state.coreVaultManager.totalRequestAmountWithFee() + getCoreVaultUnderlyingPaymentFee();
        _immediatelyAvailableUBA = MathUtils.subOrZero(availableFunds, requestedAmountWithFee);
        _totalAvailableUBA = MathUtils.subOrZero(availableFunds + escrowedFunds, requestedAmountWithFee);
    }

We can clearly see that again fee amount is taken into account while calculating the amount available. Now see in the case of non cancelable requests no new transfer request is added for the available destination address

Solidity
else {
            uint256 index = 0;
            while (index < nonCancelableTransferRequests.length) {
                TransferRequest storage req = transferRequestById[nonCancelableTransferRequests[index]];
==>                if (keccak256(bytes(req.destinationAddress)) == destinationAddressHash) {
                    // add the amount to the existing request
                    req.amount += _amount;
                    _paymentReference = req.paymentReference;   // use the old payment reference when merged
                    break;
                }
                index++;
            }
            nonCancelableTransferRequestsAmount += _amount;
            // if the request does not exist, add a new one
            if (index == nonCancelableTransferRequests.length) {
                nonCancelableTransferRequests.push(nextTransferRequestId);
                newTransferRequest = true;
            }

Therefore incorrect calculation of available amount is done. This can also cause less available lots available for example

Solidity
uint256 requestedAmountWithFee =
            state.coreVaultManager.totalRequestAmountWithFee() + getCoreVaultUnderlyingPaymentFee();
        _immediatelyAvailableUBA = MathUtils.subOrZero(availableFunds, requestedAmountWithFee);
        _totalAvailableUBA = MathUtils.subOrZero(availableFunds + escrowedFunds, requestedAmountWithFee);

Suppose total available amount after taking into account the fee is less than the lot size then the following function will return zero.

Solidity
 function getCoreVaultAmountLots()
        internal view
        returns (uint64)
    {
        AssetManagerSettings.Data storage settings = Globals.getSettings();
        (, uint256 totalAmountUBA) = getCoreVaultAvailableAmount();
        return Conversion.convertUBAToAmg(totalAmountUBA) / settings.lotSizeAMG;
    }

Now hadn't the fees been taken into account it would have returned 1 lot availble which is the correct amount available.

The original report as published on Immunefi, by swarun. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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 available-amount calculation always adds a payment fee for one more request, even when the new redeem is merged into an existing non-cancelable transfer request and no fee is actually charged.

Impact

The vault could report fewer available lots than it really has, potentially zero when one is available, causing griefing to users or the protocol.

What the attacker needed

User already has a non-cancelable request; second redeem to same destination

The fix

The available-amount calculation should only account for the fee when a new transfer request would actually be created, not when the amount is merged into an existing one.

How it was found

  1. A user has already made a redeem from the core vault, creating a non-cancelable transfer request.
  2. The same user redeems again to the same destination address, so the amount is merged into the existing request.
  3. The available-amount calculation still subtracts a fee, giving a lower total available amount.
  4. The lot count derived from that amount can show zero lots when one lot is actually available.

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 tokens and lets users request withdrawals. Each new withdrawal request normally reserves a small fee, but when a second request is merged into an existing one no new fee is taken. The code still subtracts that fee when reporting how much is available, so the vault looks emptier than it is.

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.

More by swarun

View all

7 more disclosed reports, best first.

More from Flare | FAssets

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.