Skip to content
Business logic Audit finding Intermediate

Cross-chain unstake and fast redeem operations fail due to minAmountLD not accounting for LayerZero dust removal

The cross-chain unstake and fast redeem functions set the minimum received amount equal to the full amount, but LayerZero removes dust before the slippage check, so any amount not divisible by the conversion rate reverts. This blocks users from completing cross-chain unstaking or fast redemption for most realistic amounts.

jerry0422 Follow with Albert, deeney and 14 others

Originally disclosed on Code4rena

Submitted by jerry0422, also found by Albert, deeney, djshan_eden, hecker_trieu_tien, hodlturk, jo13, lufP, Manosh19, newspacexyz, odeili, saraswati, slvDev, Smacaud, tobi0x18, web3snr, and Wojack

  • token/wiTRY/crosschain/wiTryVaultComposer.sol #L267-L268
  • token/wiTRY/crosschain/wiTryVaultComposer.sol #L116-L117

Finding description

In wiTryVaultComposer, both _handleUnstake() and _fastRedeem() set minAmountLD equal to amountLD when constructing the SendParam for cross-chain token transfers:

_handleUnstake (lines 264-272):

SendParam memory _sendParam = SendParam({
    dstEid: _origin.srcEid,
    to: bytes32(uint256(uint160(user))),
    amountLD: assets,
    minAmountLD: assets,  // @audit problematic - not accounting for dust removal
    extraOptions: options,
    composeMsg: "",
    oftCmd: ""
});

_fastRedeem (lines 116-117):

_sendParam.amountLD = assets;
_sendParam.minAmountLD = assets;  // @audit problematic - not accounting for dust removal

LayerZero OFT implements a dust removal mechanism in _debitView() to handle decimal precision differences between chains. For tokens with 18 local decimals and 6 shared decimals (the default in OFTCore.sol), the decimalConversionRate is 10^12. The _removeDust() function truncates amounts:

// OFTCore.sol
function _removeDust(uint256 _amountLD) internal view virtual returns (uint256 amountLD) {
    return (_amountLD / decimalConversionRate) * decimalConversionRate;
}

After dust removal, the OFT performs a slippage check in _debitView():

function _debitView(uint256 _amountLD, uint256 _minAmountLD, uint32)
    internal view virtual returns (uint256 amountSentLD, uint256 amountReceivedLD) {
    amountSentLD = _removeDust(_amountLD);
    amountReceivedLD = amountSentLD;

    if (amountReceivedLD < _minAmountLD) {
        revert SlippageExceeded(amountReceivedLD, _minAmountLD);
    }
}

When a user’s asset amount is not perfectly divisible by 10^12 (which is the common case for arbitrary amounts), the dust-removed amount will be less than the original, causing the slippage check to fail.

Example:

  • User unstakes 10000000000000000001 wei (10 ether + 1)
  • After _removeDust(): 10000000000000000000 (10 ether)
  • Slippage check: 10000000000000000000 < 10000000000000000001 → reverts with SlippageExceeded

Impact

Cross-chain unstaking and fast redemption functionality is broken for any asset amount containing dust (not divisible by 10^12). This affects approximately 69% of real-world transaction amounts including:

  • ERC4626 share-to-asset conversions with yield
  • Fee calculations (fast redeem fee deductions)
  • Any division operations

Users who have completed their cooldown period and attempt to unstake cross-chain will have their transactions fail, leaving their funds inaccessible through normal protocol operations until owner intervention via rescueToken().

Recommended mitigation steps

Set minAmountLD to 0 or calculate the dust-removed amount to use as the minimum:

Option 1: No slippage protection (recommended):

// Acceptable since amount is protocol-determined, not user-provided
_sendParam.minAmountLD = 0;

Option 2: Account for dust removal:

_sendParam.minAmountLD = (assets / 1e12) * 1e12;

For _handleUnstake():

SendParam memory _sendParam = SendParam({
    dstEid: _origin.srcEid,
    to: bytes32(uint256(uint160(user))),
    amountLD: assets,
-   minAmountLD: assets,
+   minAmountLD: 0,
    extraOptions: options,
    composeMsg: "",
    oftCmd: ""
});

For _fastRedeem()`:

_sendParam.amountLD = assets;
- _sendParam.minAmountLD = assets;
+ _sendParam.minAmountLD = 0;

Proof of Concept

Add DustRemovalRevert.t.sol file to the test folder:

View detailed Proof of Concept

Run the PoC:

forge test --match-contract DustRemovalRevertPOC -vv

Key test results:

  • test_POC_CoreIssue_DustRemovalCausesRevert - Confirms vulnerability with amounts containing dust
  • test_POC_ImpactScale_MostAmountsAffected - Shows 69% of realistic amounts fail (25/36 scenarios)
  • test_POC_ProofOfFix_MinAmountZero - Validates both fixes work correctly
  • test_POC_VulnerableCodePaths - Documents vulnerable locations and fix

The PoC demonstrates that any amount not perfectly divisible by 1,000,000,000,000 (1e12) will cause cross-chain operations to revert, breaking core protocol functionality.


The original report as published on Code4rena, by jerry0422. 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 code sets minAmountLD to the full asset amount without subtracting the dust that LayerZero removes during decimal conversion, so the slippage check always fails when the amount is not a multiple of the conversion rate.

Impact

Cross-chain unstaking and fast redemption fail for any amount containing dust, leaving users unable to access funds through normal operations until an owner intervenes.

What the attacker needed

User has completed cooldown; amount not divisible by 1e12

The fix

The report recommends setting minAmountLD to zero or to the dust-removed amount; it does not state that a fix was applied.

How it was found

  1. A user unstakes or fast redeems an amount that is not perfectly divisible by the conversion rate.
  2. The contract builds a cross-chain send with minAmountLD equal to the full amount.
  3. LayerZero removes dust from the amount before the slippage check.
  4. The dust-removed amount is less than minAmountLD, so the transfer reverts with SlippageExceeded.

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.

When tokens move between blockchains, the receiving chain may use fewer decimal places, so the bridge rounds the amount down by a tiny amount called dust. The code here demanded that the full original amount arrive, so the bridge's own rounding made the safety check fail and the transfer was rejected. This meant users could not unstake or redeem across chains for most amounts.

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 from Brix Money

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.