Closed c4-bot-5 closed 10 months ago
DadeKuma marked the issue as primary issue
DadeKuma marked the issue as sufficient quality report
lumtis (sponsor) confirmed
this could be viewed as a duplicate of #406 as if #406 is resolved so is this issue. Will mark as duplicate for now.
0xean marked the issue as duplicate of #406
0xean marked the issue as satisfactory
0xean marked the issue as not a duplicate
0xean marked the issue as duplicate of #401
Lines of code
https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/node/x/crosschain/keeper/gas_payment.go#L288
Vulnerability details
Impact
Users can send ZetaToken without paying out bound tx gas, cause the loss of the protocol funds.
Proof of Concept
When a user use ZetaToken send messages across the chain, in the module will use
PayGasInZetaAndUpdateCctx
to pay out bound tx gas, the function will deduct the amount of gasPrice * gasLimit out bound tx gas, and finally update the value of cctx.OutTxParam.Amount, the user will then receive the number of tokens after deducting gas and protocol fees.The problem is that
gasLimit
is obtained from the user parameter, and if the user passes in a value of 0 gasLimit, there is no need to pay for Out Tx gas(or if the user passes in a small gasLimit, the user only pays a small Out Tx gas).Other types of token
gasLimit
are fixed values obtained in the contract account viaChainGasParams
, set by the administrator, and therefore do not have this problem.When the observer processes Out Tx, the gasLimit value is less than 100_000 and is set to 100_000, so the transfer can be executed.
Let's take a look at the code:
gasLimit is obtained from the OutboundTxGasLimit parameter:
destinationGasLimit is OutboundTxGasLimit:
Set OutboundTxGasLimit when creating the cctx:
msg.GasLimit is parsed from the event:
When the observer processes out tx, the gasLimit value is less than 100_000 and is set to 100_000:
Tools Used
vscode manual
Recommended Mitigation Steps
Set a minimum value that is used when the OutboundTxGasLimit is less than the minimum
Assessed type
Other