`GlobalVariables::oftOrCollateralReceiveFromOtherChains()` calculates the fee as if it was the same in both chains, which is false
The fee calculation in a cross-chain receive function assumed the transfer direction was from the current chain to the destination, when the actual direction is the reverse. This could cause the fee to be overcharged or undercharged, leading to reverts on the destination chain.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/795
Found by
0x73696d616f
Summary
GlobalVariables::oftOrCollateralReceiveFromOtherChains() send a message to the other chain requesting token/eth transfers to the current chain. In the process, it forwards ETH to pay for the cross chain transfer from the destination to the current chain. However, it calculates the fee as if the direction was current to destination, when in reality it is the opposite and the fee will be different. Thus, it will either overchage or revert in the destination chain.
Root Cause
In GlobalVariables::oftOrCollateralReceiveFromOtherChains() fee is calculated as if the direction is current to destination, when it is the opposite.
Internal pre-conditions
None.
External pre-conditions
None.
Attack Path
GlobalVariables::oftOrCollateralReceiveFromOtherChains()is called, but the fee is incorrectly calculated.
Impact
Overcharging of the fee or charging too little, which will lead to reverts on the destination chain.
PoC
See links.
Mitigation
Add a variable admin set to track the costs.
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
Impact
The fee could be overcharged or undercharged, which could cause the transfer to revert on the destination chain.
What the attacker needed
None
The fix
The report suggests adding an admin-set variable to track the costs, so the correct fee for each direction is used.
How it was found
- Call the cross-chain receive function, which forwards ETH to pay for the transfer back to the current chain.
- Observe that the fee was calculated for the wrong direction, so the amount is incorrect.
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 one blockchain sends a message to another, a fee is paid to cover the cost of the transfer. The fee depends on which direction the transfer goes, because each chain has its own pricing. Here the code used the wrong direction when estimating the fee, so the amount sent was wrong and the transfer could fail on the other side.
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.