The StarklaneState(State)
contract allows the owner to set L2 addresses and selectors without validating the input. This lack of validation can lead to the setting of invalid or unintended values, potentially causing operational failures or security risks.
1.Zero Value Case:
Scenario:
Contract owner accidentally calls setStarklaneL2Address(0)
.
Steps:
Contract owner calls setStarklaneL2Address
function with parameter 0
.
The function sets _starklaneL2Address
to 0
without validation.
Another contract or a function within this contract tries to send a message to L2 using _starklaneL2Address
.
The message fails because 0
is not a valid address in Starknet.
2.Invalid Value Case:
Scenario:
Contract owner calls setStarklaneL2Selector(12345678901234567890)
without knowing that the selector does not exist in the L2 contract.
Steps:
Contract owner calls the setStarklaneL2Selector
function with the parameter 12345678901234567890
.
The function sets _starklaneL2Selector
to 12345678901234567890
without validation.
Contract tries to send a message to L2 using _starklaneL2Selector
.
The message fails because the selector 12345678901234567890
does not exist in the target L2 contract.
3.Unwanted Value Case:
Scenario:
Contract owner calls setStarklaneL2Address
with wrong address due to typo, for example setStarklaneL2Address(0x1234...5678)
instead of 0x1234...5679
.
Steps:
Contract owner calls setStarklaneL2Address
function with parameter 0x1234...5678
.
Function sets _starklaneL2Address
to 0x1234...5678
without validation.
Contract tries to send message to L2 using _starklaneL2Address
.
Message is sent to wrong address (0x1234...5678
instead of 0x1234...5679
).
forge test --match-path test/StarklaneStateTest.t.sol
[⠊] Compiling...
[⠃] Compiling 1 files with Solc 0.8.26
[⠊] Solc 0.8.26 finished in 792.11ms
Compiler run successful!
Ran 3 tests for test/StarklaneStateTest.t.sol:StarklaneStateTest
[PASS] testInvalidSelector() (gas: 32828)
[PASS] testUnwantedValue() (gas: 32818)
[PASS] testZeroValue() (gas: 12886)
Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 46.72ms (12.56ms CPU time)
Ran 1 test suite in 80.95ms (46.72ms CPU time): 3 tests passed, 0 failed, 0 skipped (3 total tests)
1.Zero Value:
Setting the L2 address or selector to zero can cause operational failures as zero is often used to indicate uninitialized or invalid states.
2.Invalid or Unintended Values:
Setting excessively large or unintended values can lead to messages being sent to incorrect addresses or functions, resulting in failed transactions and potential loss of funds.
Operational disruptions can occur if the contract relies on specific addresses or selectors to function correctly.
Manual review
Foundry
Implement input validation to ensure that the L2 address and selector are valid and within acceptable ranges.
Emit events when setting the L2 address and selector to facilitate off-chain monitoring and auditing.
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.