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.
Originally disclosed on Code4rena
Submitted by farman1094
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,
-
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
newRedemptionRequestIdas 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.newRedemptionRequestIdcan easily fetch through chain, slot is 14 need to decoding 8 byte.``` |---------------------------------------+-------------------------------------------------------+------+--------+-------+----------------------------------------------------------| | newRedemptionRequestId | uint64 | 14 | 8 | 8 | |---------------------------------------+-------------------------------------------------------+------+--------+-------+----------------------------------------------------------| ``` -
PaymentReference.randomizedIdSkipcan be guessed through the block number,
-
-
After payment agent can initiate the request from the
CoreVaultClientFacet::transferToCoreVaultwhich will return the same payment id which we have already used in form of standard payment reference for agent’s another address. -
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
blockNumberbefore therequest.firstUnderlyingBlockso this payment proof cannot be submitted inRedemptionConfirmationsFacet::confirmRedemptionPayment. If submitted, the above check will save this by reverting, underlying balance cannot be decreased.
- The payment made with
-
Even though
RedemptionDefaultsFacet::executeDefaultOrCancelthis request maybe can defaulted but this is only cancel thetransferToCoreVaultrequest and this will update redeem status todefaultednot 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; } -
Now come to this this payment also cannot be challenged
ChallengesFacet::illegalPaymentChallengeand nor fromChallengesFacet::freeBalanceNegativeChallengeBecause:ChallengesFacet::illegalPaymentChallengethis check will save this here the whole transaction revert even though it supposed to highlight this as illegalrequire(!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()); } -
This transaction will not be highlighted to
ChallengesFacet::freeBalanceNegativeChallengein order to liquidate the agent because the payment agent made to his another address is same asredemptionValue.// `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
balanceAfterPaymentsis less as becauseredemptionValuedecreased fromspentAmount. This check will here save this from liquidating the Agentrequire(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", []);
}
Payments made before first redemption block can be challenged.
Status: Mitigation confirmed. Full details in reports from givn, rvierdiiev, and farman1094.
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
- The agent makes a payment on the underlying chain to another of their own addresses, using a valid redemption payment reference.
- The agent later initiates a transferToCoreVault request that returns the same payment reference.
- The agent attempts to confirm the redemption payment, but the block number check reverts because the payment was made before the request's firstUnderlyingBlock.
- The agent attempts an illegalPaymentChallenge, but it reverts with MatchingRedemptionActive because the redemption is still open.
- 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.