The Starklane(Bridge) Bridge Contract contains two critical vulnerabilities: an unbounded loop in the getWhiteListedCollections
function and insufficient input validation in the setL1L2CollectionMapping
function. These issues can lead to denial of service, functional disruptions, and potential asset loss.
This bug is caused by the lack of control access on _withdrawFromEscrow
which I explained in the previous report: https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/Escrow.sol#L63-L89
Unbounded Loop in getWhiteListedCollections
:
The getWhiteListedCollections
function iterates over the entire _collections
array without any upper limit.
This can lead to excessive gas consumption, especially when the array grows large due to multiple collections being added.
Lack of Input Validation in setL1L2CollectionMapping
:
The setL1L2CollectionMapping
function does not validate the input addresses.
Invalid addresses can be set, disrupting the contract's functionality.
forge test --match-path test/ExploitTests.t.sol
[⠊] Compiling...
No files changed, compilation skipped
Ran 2 tests for test/ExploitTests.t.sol:ExploitTests
[PASS] testLackOfInputValidation() (gas: 61823)
[PASS] testUnboundedLoop() (gas: 181264591)
Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 91.31ms (85.11ms CPU time)
Ran 1 test suite in 102.98ms (91.31ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)
Unbounded Loop: Denial of Service, Operational Disruption
Lack of Input Validation: Functional Disruption, Security Risks
Manual review
Foundry
Implement a maximum limit on the number of collections that can be added to the whitelist.
Make sure the address is valid.
Access Control: Ensure that sensitive functions are protected with appropriate access control mechanisms.
Gas Optimization: Regularly review and optimize functions that may consume excessive gas.
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.