Potential loss of capital due to fixed fee calculations
The StargateBridgeAdapter uses a fixed fee calculation (0.06% of the current Stargate fee) that does not account for Stargate's variable fees, which can be adjusted to incentivise swaps. As a result, the callback on the target chain may receive more tokens than the expected amountIn, and the excess is lost in the adapter.
Soliditors Follow with Soliditors, gesha17 and 3 others
Originally disclosed on Code4rena
Submitted by Soliditors, also found by Soliditors, windhustler (1, 2), gesha17, wangxx2026, NentoR, and peanuts
The StargateBridgeAdapter relies on a fixed fee calculation (0.06% of the current Stargate fee), but as explained in the Stargate documentation, fees can be automatically adjusted to meet demand. (here)
This reward can be adjusted (StargateFeeLibraryV02.sol#L68) to “To incentivize users to conduct swaps that ‘refill’ native asset balances”. A problem arises because the StargateBridgeAdapter doesn’t account for this variable fee.
Then the callback function (triggered on the target chain) will receive a token amount greater than amountIn. StargateBridgeAdapter.sol#L207
IERC20(swapParams.tokenIn).approve(utb, swapParams.amountIn);
As you can see, here the difference between the received amount StargateBridgeAdapter.sol#L188 and swapParams.amountIn gets lost in the adapter.
Recommended Mitigation Steps
It’s recommended approve the amountLD instead of the swapParams.amountIn . This way, all token received during the callback will be transfered.
function sgReceive(
uint16, // _srcChainid
bytes memory, // _srcAddress
uint256, // _nonce
- address, // _token
- uint256, // amountLD
+ address _token,
+ uint256 amountLD,
bytes memory payload
) external override onlyExecutor {
(
SwapInstructions memory postBridge,
address target,
address paymentOperator,
bytes memory utbPayload,
address payable refund
) = abi.decode(
payload,
(SwapInstructions, address, address, bytes, address)
);
SwapParams memory swapParams = abi.decode(
postBridge.swapPayload,
(SwapParams)
);
- IERC20(swapParams.tokenIn).approve(utb, swapParams.amountIn);
+ IERC20(_token).approve(utb, amountLD); // _token == swapParams.tokenIn
+ swapParams.amountIn = amountLD // swapParams also needs to be updated to swap the correct amount
+ postBridge.swapPayload = abi.encode(swapParams);
IUTB(utb).receiveFromBridge(
postBridge,
target,
paymentOperator,
utbPayload,
refund
);
}
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 adapter approves only the originally calculated amountIn instead of the actual received amountLD, so any excess tokens received due to variable bridge fees remain stuck in the adapter.
What the attacker needed
Stargate fee is lower than expected; User bridges tokens via StargateBridgeAdapter
The fix
The adapter should approve the actual received amountLD instead of swapParams.amountIn, and update swapParams.amountIn accordingly, so all received tokens are transferred.
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 you send tokens across chains using a bridge, the bridge charges a fee. This adapter assumed the fee would always be a fixed percentage, but the bridge can change its fee to encourage certain swaps. If the fee is lower than expected, the adapter receives more tokens than it planned to use, and the extra tokens get stuck in the adapter instead of being passed on.
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.