A logical bug was identified in the StarklaneMessaging
Solidity contract, specifically within the _consumeMessageStarknet
function. The bug allows a message to be consumed inadvertently before verifying its status, leading to potential inconsistencies and reversion of transactions. This report details the nature of the bug, its impact, and provides recommendations to resolve the issue.
The _consumeMessageStarknet
function attempts to consume a message from the Starknet core contract using the consumeMessageFromL2
method. This method consumes the message and returns its hash. The function then checks if the message was intended for auto-withdraw by looking up the _autoWithdrawn
mapping. If the message was meant for auto-withdraw, the function reverts with WithdrawMethodError
.
However, the consumption of the message occurs before this verification, leading to a scenario where the message is consumed but the transaction is reverted, making the message non-reusable and causing inconsistencies.
Original Code with Bug:
Corrected Code:
The impact of this bug is significant as it can lead to message consumption before proper verification, causing unintended transaction reversion. This can result in:
Inconsistent state within the contract.
Loss of messages that cannot be reused.
Potential denial of service due to frequent reversion of transactions.
To resolve this issue, it is recommended to:
Compute the msgHash
and verify its status in the _autoWithdrawn
mapping before consuming the message.
Only proceed with the message consumption if it is valid for the Starknet method.
Ensure thorough testing and verification of the contract logic to prevent similar issues in the future.
By implementing these changes, the contract will correctly handle message consumption, maintaining consistency and preventing unintended reversion of transactions.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.