https://github.com/Cyfrin/2024-07-ark-project/blob/main/apps/blockchain/starknet/src/bridge.cairo
The functions withdraw_auto_from_l1
and deposit_tokens
contain loops that iterate over token IDs provided in requests. These loops do not have a cap on the number of iterations, allowing an attacker to create requests with an extremely large number of token IDs.
An attacker can submit a request with a very large number of token IDs, causing the loops to consume an excessive amount of gas. This can lead to transactions exceeding the block gas limit, making it impossible to complete the function execution and preventing legitimate users from processing their requests.
Here is a Solidity contract that exploits the vulnerability:
A Foundry test script to deploy the vulnerable contract, deploy the exploit contract, and perform the attack.
This code demonstrates how an attacker can exploit the unbounded loop in the withdraw_auto_from_l1
function to cause a DoS attack. The exploit contract constructs a request with a large number of token IDs and calls the vulnerable function, consuming excessive gas and potentially exhausting the block gas limit. The Foundry test script deploys both the vulnerable and exploit contracts and executes the attack.
By running this test, you can observe the effects of the attack and verify the vulnerability. This approach can be extended to test other identified vulnerabilities and their potential exploits.
An attacker can exploit the unbounded loop to consume excessive gas. This can lead to transaction failures or exhaust the block gas limit, making the function unusable. This kind of disruption can significantly affect the contract's availability, especially if the function is crucial for operations such as token withdrawals.
Users may not be able to perform essential actions, leading to operational issues and potential financial impact due to the inability to withdraw tokens
Manual review
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.