NFTBridge
60,000 USDC
View results
Submission Details
Severity: medium
Valid

Insufficient Fee Validation in L1-L2 Message Transmission

Overview

The Starklane contract on Ethereum (L1) lacks proper validation of transaction fees (msg.value) when initiating messages to Starknet (L2). This oversight can result in message transmission failures due to inadequate gas allocation.

Vulnerability Details

Location

Function: depositTokens
File: Bridge.sol

Description

The depositTokens function forwards the entire msg.value to the Starknet messaging contract without validating its sufficiency:

IStarknetMessaging(_starknetCoreAddress).sendMessageToL2{value: msg.value}(
snaddress.unwrap(_starklaneL2Address),
felt252.unwrap(_starklaneL2Selector),
payload
);

According to Starknet documentation, a minimum of 20,000 wei is required to cover the gas costs associated with storing the message hash on L1.

Impact

  1. Message Failure: Transactions with insufficient fees may fail to properly transmit messages to L2.

  2. Stuck Assets: NFTs could become temporarily locked in the bridge contract if associated messages fail to process.

  3. User Experience: Users may need to initiate cancellation procedures after a 7-day waiting period to recover from failed transfers.

  4. Increased Operational Overhead: The bridge operators may face an increased volume of support requests related to stuck transfers.

Risk Assessment

  • Severity: Medium

  • Likelihood: Medium (due to potential user error in fee estimation)

Reproduction Steps

  1. Initiate a depositTokens transaction with msg.value < 20,000 wei.

  2. Observe that the transaction completes on L1 but fails to properly transmit to L2.

Mitigation

Recommended Fix

Implement a fee validation check in the depositTokens function:

function depositTokens(...) external payable {
require(msg.value >= 20000, "Insufficient fee for L1-L2 message");
// ... existing function logic ...
}

From starknet documentation, https://docs.starknet.io/architecture-and-concepts/network-architecture/messaging-mechanism/#hashing_l2-l1 :

Sending an L2 to L1 message always incurs a fixed cost of 20,000 gas, because the hash of the message being sent must be written to L1 storage in the Starknet Core Contract.

References

  1. Cairo Book: L1-L2 Messaging

  2. Starknet Messaging Protocol Specification

Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-not-enough-fee-can-block-NFT

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

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.