GlobalVariables::oftOrCollateralReceiveFromOtherChains() calculates the fee as if it was the same in both chains, which is false
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.