Lack of strict validation for gas limit because of 1 / 64 rules allow cross-chain transaction to be executed in gas limit that is less than use specify #180
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
duplicate-97
🤖_115_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-03-taiko/blob/f58384f44dbf4c6535264a472322322705133b11/packages/protocol/contracts/bridge/Bridge.sol#L217
https://github.com/code-423n4/2024-03-taiko/blob/f58384f44dbf4c6535264a472322322705133b11/packages/protocol/contracts/bridge/Bridge.sol#L282
https://github.com/code-423n4/2024-03-taiko/blob/f58384f44dbf4c6535264a472322322705133b11/packages/protocol/contracts/bridge/Bridge.sol#L491
Vulnerability details
Lack of strict validation for gas limit because of 1 / 64 rules allow cross-chain transaction to be executed in gas limit that is less than use specify
Line of code
Proof of concept
When sending cross chain from source chain to target chain,
anyone can process the message permissionlessly if the gaslimit is set to a non-zero value
Line of code
then inside the function we call these lines of code
the gas limit is passed into the function
_invokeMessageCall
Line of code
Impact
But Because
refer to eip-150 specification
the 1/64 rules presences, only the 63/64 gas from gas limit is passed and spent to execute the message
then malicious user can ensure that the 63 / 64 of gasleft() is less than the message.gasLimit to make message executes but failed
The following POC shows that lack of validation on the gas limit results in failed transaction
running 3500 for loop would cost 63513 unit of gas
but if we specify gas limit as 64000, because only 63 / 64 of gas is passed to external call, the external transaction can still marked as failed
because this allows the external transaction executes in the gas limit less than user specify
Recommendation
The recommendation is check :
to make sure that the gas spend on execute message is at least the
message.gasLimit
user requiresAssessed type
ETH-Transfer
The text was updated successfully, but these errors were encountered: