The sendMessageToL2
function in the StarknetMessaging
contract facilitates sending messages from the Ethereum network to the Starknet network. However, there is a critical oversight in how this function handles the gas fees associated with bridging. Specifically, the function does not verify whether the msg.value
is sufficient to cover the bridging fee. This vulnerability enables users to send messages across the bridge while paying little to no fees, leading to potential revenue loss for the protocol.
In the code snippet above, the function only checks two things regarding the msg.value
:
Whether msg.value
is greater than zero.
Whether msg.value
does not exceed the maximum allowed fee (getMaxL1MsgFee()
).
However, the function does not verify if the msg.value
is sufficient to cover the actual gas fees required for the bridge operation. This lack of a minimum fee check means that a user can send just 1 wei
to meet the non-zero requirement, allowing them to send messages across the bridge almost for free.
This vulnerability could result in users exploiting the bridge by paying negligible fees. As a consequence, the protocol could face significant revenue losses, as users would be utilizing the bridging service without contributing their fair share of the fees.
Manual Review
The protocol’s documentation includes a section on estimating gas fees for bridging. The ideal approach to mitigating this vulnerability would involve calculating the bridging fee based on the size of the payload being sent. The sendMessageToL2
function should then verify that the msg.value
provided by the user is at least equal to this calculated fee.
Alternatively, the protocol could set a minimum required gas fee and enforce that the msg.value
is greater than or equal to this minimum amount.
Additionally, although not directly related to this issue, it is advisable to implement a mechanism that returns any excess gas fees to the user. This would ensure that users do not overpay for the bridging service.
Impact: Medium/High. Need an admin to start a cancellation and wait for 5 days once done. DoS > 5 days. Likelyhood: Low. Everytime a wallet/or a user do not send enough gas
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.