The Starklane bridge contract contains a vulnerability that allows an attacker to bypass the MAX_PAYLOAD_LENGTH = 300
check in the Bridge:withdrawTokens
function. This could potentially lead to the processing of oversized payloads, causing unexpected behavior or denial of service.
The withdrawTokens function in the Starklane contract (Bridge.sol) is designed to process token withdrawals from L2 to L1. It uses a constant MAX_PAYLOAD_LENGTH (set to 300) to limit the size of incoming payloads using Bridge::depositTokens
. However, this check is implemented in the Bridge::depositTokens
function but not in the Bridge:withdrawTokens
function.
Assuming you have followed the contest setup, copy and past the following test in the Bridge.t.sol file, and run the following command : forge test --mt testWithdraw10000Tokens -vv
You should get this input :
The purpose of testWithdraw10000Tokens
function is to see if we can withdraw Tokens beyond MAX_PAYLOAD_LENGTH = 300
. As you can see above the request's payload is 20020 way above the limit (300) and we can indeed remove all the tokens from the request.
The ability to bypass the MAX_PAYLOAD_LENGTH
limit in the Bridge::withdrawTokens
function exposes the Starklane bridge to severe Denial of Service (DoS) attacks, primarily through the exploitation of block gas limits. This vulnerability presents a critical threat to the operational stability and throughput of the bridge.
The test demonstrates that withdrawing 10,000 tokens consumes 357,851,945 gas. Ethereum's current block gas limit is around 30,000,000 gas. A single withdrawal transaction of this size would consume approximately 11.93 entire blocks' worth of gas.
An attacker could submit multiple such transactions, potentially consuming dozens of blocks. Legitimate transactions would face extreme delays or consistent failures due to lack of block space. Given that a normal Ethereum transaction uses about 21,000 gas, one of these malicious withdrawals is equivalent to about 17,040 standard transactions.
Users might be forced to pay exorbitant fees to have any chance of their transactions being processed. This could make the bridge economically non-viable for most users during the attack. Attackers could time these massive withdrawals to coincide with known high-traffic periods.
Foundry
Implement a payload size check in the Bridge::depositTokens
function:
Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.
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.