Skip to content
Business logic Audit finding Advanced

Agent underlying balance can be inflated, which cannot be prove-able to challenge it as illegal.

An agent could make a payment to another of their own addresses using a valid redemption payment reference, then later create a transferToCoreVault request that reuses the same reference. Because the payment was made before the request's firstUnderlyingBlock, it could not be proven as an illegal payment or used to show a negative free balance, allowing the agent to inflate their underlying balance and mint more FAsset than they held.

farman1094 Follow

Originally disclosed on Code4rena

Submitted by farman1094

https://github.com/code-423n4/2025-08-flare/blob/7bcf1437ddd739a15f8aa1b588fcc17eb66d2f31/contracts/assetManager/facets/CoreVaultClientFacet.sol#L71-L72

Finding Description

This issue is agent can make the payment to one of his another address, and later use this amount to top-up himself. According to the protocol, this shouldn’t be happening or should be considered illegal. But the agent can able to done it that way it wouldn’t be provable on FAsset mechanism, that this is illegal or agent underlying balance has decreased.

There are multiple things which make this possible,

  1. First agent will make a payment to any of his other address to use this amount later for top-up,

    • This payment will be made using a valid payment address of redeem which also include newRedemptionRequestId as standard payment reference which will not be problem to calculate.

      function _newRequestId(bool _poolSelfClose)
              private
              returns (uint64)
          {
              AssetManagerState.State storage state = AssetManagerState.get();
              uint64 nextRequestId = state.newRedemptionRequestId + PaymentReference.randomizedIdSkip();
              // the requestId will indicate in the lowest bit whether it is a pool self close redemption
              // (+1 is added so that the request id still increases after clearing lowest bit)
              uint64 requestId = ((nextRequestId + 1) & ~uint64(1)) | (_poolSelfClose ? 1 : 0);
              state.newRedemptionRequestId = requestId;
              return requestId;
          }
      
    • state.newRedemptionRequestId can easily fetch through chain, slot is 14 need to decoding 8 byte.

      ```
      |---------------------------------------+-------------------------------------------------------+------+--------+-------+----------------------------------------------------------|
      | newRedemptionRequestId                | uint64                                                | 14   | 8      | 8     |
      |---------------------------------------+-------------------------------------------------------+------+--------+-------+----------------------------------------------------------|
      ```
      
    • PaymentReference.randomizedIdSkip can be guessed through the block number,

  2. After payment agent can initiate the request from the CoreVaultClientFacet::transferToCoreVault which will return the same payment id which we have already used in form of standard payment reference for agent’s another address.

  3. As the payment has already been made with the payment reference and the request created later we made this check vulnerable.

    // RedemptionConfirmationsFacet::confirmRedemptionPayment
    require(_payment.data.responseBody.blockNumber >= request.firstUnderlyingBlock,
    
    • The payment made with blockNumber before the request.firstUnderlyingBlock so this payment proof cannot be submitted in RedemptionConfirmationsFacet::confirmRedemptionPayment. If submitted, the above check will save this by reverting, underlying balance cannot be decreased.
  4. Even though RedemptionDefaultsFacet::executeDefaultOrCancel this request maybe can defaulted but this is only cancel the transferToCoreVault request and this will update redeem status to defaulted not close, which is considered open.

    // RedemptionDefaultsFacet::redemptionPaymentDefault
        request.status = Redemption.Status.DEFAULTED;
    
    • Redemptions.isOpen(redemption) the defaulted considered open
        // true if redemption is valid and has not been confirmed yet
        function isOpen(Redemption.Request storage _request)
            internal view
            returns (bool)
        {
            Redemption.Status status = _request.status;
            return status == Redemption.Status.ACTIVE || status == Redemption.Status.DEFAULTED;
        }
    
  5. Now come to this this payment also cannot be challenged ChallengesFacet::illegalPaymentChallenge and nor from ChallengesFacet::freeBalanceNegativeChallenge Because:

    • ChallengesFacet::illegalPaymentChallenge this check will save this here the whole transaction revert even though it supposed to highlight this as illegal require(!redemptionActive, MatchingRedemptionActive()); because the payment to different address not to the underlying address of core vault.
    // ChallengesFacet::illegalPaymentChallenge
        if (paymentReference != 0) {
    if (PaymentReference.isValid(paymentReference, PaymentReference.REDEMPTION)) {
    uint256 redemptionId = PaymentReference.decodeId(paymentReference);
    Redemption.Request storage redemption = state.redemptionRequests[redemptionId];
    // Redemption must be for the correct agent, must not be rejected and
    // only statuses ACTIVE and DEFAULTED mean that redemption is still missing a payment proof.
    // We do not check for timestamp of the payment, because on UTXO chains legal payments can be
    // delayed by arbitrary time due to high fees and cannot be canceled, which could lead to
    // unnecessary full liquidations.
    bool redemptionActive = redemption.agentVault == _agentVault && Redemptions.isOpen(redemption);
    require(!redemptionActive, MatchingRedemptionActive());
                }
    
  6. This transaction will not be highlighted to ChallengesFacet::freeBalanceNegativeChallenge in order to liquidate the agent because the payment agent made to his another address is same as redemptionValue.

    //   `ChallengesFacet::freeBalanceNegativeChallenge`
    bytes32 paymentReference = pmi.data.responseBody.standardPaymentReference;
    if (PaymentReference.isValid(paymentReference, PaymentReference.REDEMPTION)) {
    // for open redemption, we don't count the value that should be paid to free balance deduction.
    // Note that we don't need to check that the redemption is for this agent, because payments
    // with redemption reference for other agent can be immediatelly challenged as illegal.
    uint256 redemptionId = PaymentReference.decodeId(pmi.data.responseBody.standardPaymentReference);
    Redemption.Request storage request = state.redemptionRequests[redemptionId];
    uint256 redemptionValue = Redemptions.isOpen(request) ? request.underlyingValueUBA : 0;
    total += pmi.data.responseBody.spentAmount - SafeCast.toInt256(redemptionValue);
    
    • So this would not be prove balanceAfterPayments is less as because redemptionValue decreased from spentAmount. This check will here save this from liquidating the Agent

      require(balanceAfterPayments < requiredBalance.toInt256(), MultiplePaymentsChallengeEnoughBalance());
      

Impact

Agent underlying balance is inflated by request.underlyingValueUBA; which is not provable. The agent able to mint more FAsset even without holding it underlying chain.

Proof of Concept

Update the code in: test/integration/assetManager/05-RedemptionConfirmationByOthers.ts.

Use this command to run this specific test:

npx hardhat test test/integration/assetManager/05-RedemptionConfirmationByOthers.ts --grep "test issue default payment reference payment cannot highlighted as illegal"

The POC highlights any redemption request which has been defaulted if the payment reference of that request has been used in underlying chain for the payment to anyone by agent. They cannot be highlighted as in ChallengesFacet by both functions: illegalPaymentChallenge or freeBalanceNegativeChallenge.

        it("test issue default payment reference payment cannot highlighted as illegal", async () => {
            const agent = await Agent.createTest(context, agentOwner1, underlyingAgent1);
            const minter = await Minter.createTest(context, minterAddress1, underlyingMinter1, context.underlyingAmount(10000));
            const redeemer = await Redeemer.create(context, redeemerAddress1, underlyingRedeemer1);
            const challenger = await Challenger.create(context, challengerAddress1);
            // make agent available
            const fullAgentCollateral = toWei(3e8);
            await agent.depositCollateralsAndMakeAvailable(fullAgentCollateral, fullAgentCollateral);
            // update block
            await context.updateUnderlyingBlock();
            // perform minting
            const lots = 3;
            const crt = await minter.reserveCollateral(agent.vaultAddress, lots);
            const txHash = await minter.performMintingPayment(crt);
            const minted = await minter.executeMinting(crt, txHash);
            assertWeb3Equal(minted.mintedAmountUBA, context.convertLotsToUBA(lots));
            // redeemer "buys" f-assets
            await context.fAsset.transfer(redeemer.address, minted.mintedAmountUBA, { from: minter.address });
            // perform redemption
            await context.updateUnderlyingBlock();
            const [redemptionRequests, remainingLots, dustChanges] = await redeemer.requestRedemption(lots);
            assertWeb3Equal(remainingLots, 0);
            assert.equal(dustChanges.length, 0);
            assert.equal(redemptionRequests.length, 1);
            const request = redemptionRequests[0];
            assert.equal(request.agentVault, agent.vaultAddress);
            // mine some blocks to create overflow block
            for (let i = 0; i <= context.chainInfo.underlyingBlocksForPayment + 10; i++) {
                await minter.wallet.addTransaction(minter.underlyingAddress, minter.underlyingAddress, 1, null);
            }
            // test rewarding for redemption payment default
            const startVaultCollateralBalanceRedeemer = await agent.vaultCollateralToken().balanceOf(redeemer.address);
            const startVaultCollateralBalanceAgent = await agent.vaultCollateralToken().balanceOf(agent.agentVault.address);
            const startPoolBalanceRedeemer = await context.wNat.balanceOf(redeemer.address);
            const startPoolBalanceAgent = await agent.poolCollateralBalance();
            await agent.checkAgentInfo({ totalVaultCollateralWei: fullAgentCollateral, freeUnderlyingBalanceUBA: minted.agentFeeUBA, mintedUBA: minted.poolFeeUBA, reservedUBA: 0, redeemingUBA: request.valueUBA });
            const res = await redeemer.redemptionPaymentDefault(request);
            const randomAddr = "SomeOtherAddress";
            const tx1Hash = await agent.performPayment(underlyingRedeemer2, request.valueUBA, request.paymentReference);
            await expectRevert.custom(challenger.illegalPaymentChallenge(agent, tx1Hash), "MatchingRedemptionActive", []);
            await expectRevert.custom(challenger.freeBalanceNegativeChallenge(agent, [tx1Hash]), "MultiplePaymentsChallengeEnoughBalance", []);
        }

Flare mitigated:

Payments made before first redemption block can be challenged.

Status: Mitigation confirmed. Full details in reports from givn, rvierdiiev, and farman1094.


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

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 protocol only checks that a payment's block number is not before the redemption request's firstUnderlyingBlock when confirming a redemption, but does not apply the same timing check when challenging an illegal payment or a negative free balance, so a payment made before the request can be reused without being flagged.

Impact

The agent's underlying balance could be inflated by the redemption value, allowing them to mint more FAsset than they actually held on the underlying chain, and this could not be proven as illegal through the existing challenge functions.

What the attacker needed

Agent role with collateral; ability to make underlying payments; ability to create redemption requests

The fix

The protocol was mitigated by allowing payments made before the first redemption block to be challenged.

How it was found

  1. The agent makes a payment on the underlying chain to another of their own addresses, using a valid redemption payment reference.
  2. The agent later initiates a transferToCoreVault request that returns the same payment reference.
  3. The agent attempts to confirm the redemption payment, but the block number check reverts because the payment was made before the request's firstUnderlyingBlock.
  4. The agent attempts an illegalPaymentChallenge, but it reverts with MatchingRedemptionActive because the redemption is still open.
  5. The agent attempts a freeBalanceNegativeChallenge, but it reverts with MultiplePaymentsChallengeEnoughBalance because the redemption value is subtracted from the spent amount.

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.

An agent is someone who holds collateral and processes redemptions for the protocol. They are supposed to pay the redeemer on the underlying chain and prove it. Here the agent paid themselves instead, using a payment reference that looked like a real redemption, and then created a request that reused that reference. The protocol's checks could not flag this as illegal because the payment happened before the request existed, so the agent's balance appeared higher than it really was.

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 farman1094

View all

11 more disclosed reports, best first.

More from Flare - FAsset

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.