-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LayerZeroModule miscalculates gas, risking loss of assets #445
Comments
Might also cause the LZ channel to stuck #244 |
I respectfully disagree that this is even a valid issue. |
Maybe I am miss-understanding something, so some clarification would be great if you think I'm wrong on this. |
Please take a look at LayerZeroModule.sol 's send function:
The function uses _baseGas() and _gasPerByte() as the relayer adapter parameters as described in the submission description's link. These two getters are global for all chains. I agree that the getMessage() function takes into account the correct fees for the destination chain. |
Ya but these refer to destination gas limits. BaseGas and GasPerByte is the amount of gas that is used by the |
Discussed this in more detail with @trust1995, definitely a critical issue. |
Lines of code
https://github.com/code-423n4/2022-10-holograph/blob/f8c2eae866280a1acfdc8a8352401ed031be1373/contracts/module/LayerZeroModule.sol#L431-L445
Vulnerability details
Description
Holograph gets it's cross chain messaging primitives through Layer Zero. To get pricing estimate, it uses the DstConfig price struct exposed in LZ's RelayerV2
The issue is that the important baseGas and gasPerByte configuration parameters, which are used to calculate a custom amount of gas for the destination LZ message, use the values that come from the source chain. This is in contrast to LZ which handles DstConfigs in a mapping keyed by chainID. The encoded gas amount is described here
Impact
The impact is that when those fields are different between chains, one of two things may happen:
The code does not handle a failed lzReceive (differently to a failed executeJob). Therefore, no failure event is emitted and the NFT is screwed.
Tools Used
Manual audit
Recommended Mitigation Steps
Firstly,make sure to use the target gas costs.
Secondly, re-engineer lzReceive to be fault-proof, i.e. save some gas to emit result event.
The text was updated successfully, but these errors were encountered: