Closed c4-bot-7 closed 4 months ago
saxenism (sponsor) disputed
We don't see the issue here, the warden can provide more concrete and statistical impact explanation if they want.
The Warden attempts to articulate a flaw in the Mailbox::l2TransactionBaseCost
function, however, no clear flaw is identified and I do not envision any apparent issue arising from the Warden's submission. As such, I consider it to have insufficient proof.
alex-ppg marked the issue as unsatisfactory: Insufficient proof
Lines of code
https://github.com/code-423n4/2024-03-zksync/blob/0ac7f015e6d091eba444fe6e490a85e3ee4faf79/code/contracts/ethereum/contracts/state-transition/chain-deps/facets/Mailbox.sol#L143-L175
Vulnerability details
The function
l2TransactionBaseCost
inMailbox.sol
is responsible for calculating the L2 Transaction Base Cost. The parameters_gasPrice
,_l2GasLimit
, and_l2GasPerPubdataByteLimit
lack any value range checks, leading to occasionally large calculation results.Moreover, there are issues with the test code for this function, and the correctness of its internal logic needs verification.
Impact
Proof of Concept
l2TransactionBaseCost
and the function_deriveL2GasPrice
it calls do not perform any validation on external input parameters. https://github.com/code-423n4/2024-03-zksync/blob/0ac7f015e6d091eba444fe6e490a85e3ee4faf79/code/contracts/ethereum/contracts/state-transition/chain-deps/facets/Mailbox.sol#L143-L175The function
test_l2TransactionBaseCost
in the test codeexperimental_bridge.t.sol
is used to indirectly test the same function inMailbox.sol
by testingbridgeHub.l2TransactionBaseCost
. However, there are issues with this test code:Regardless of the input parameters, the test always passes.
This is because
vm.mockCall
has fixed the return value ofl2TransactionBaseCost
to bemockL2TxnCost
, making the test tautological.Using Fuzz Testing cannot verify the logic and correctness of the
l2TransactionBaseCost
function. The calculation of L2TxnCost depends onmockGasPrice
,mockL2GasLimit
, andmockL2GasPerPubdataByteLimit
, so these four parameters, especiallymockL2TxnCost
, cannot be arbitrarily input. Manually inputting parameters and only changing the value ofmockL2TxnCost
still passes the test.Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.59ms
Ran 1 test suite in 2.59ms: 1 tests passed, 0 failed, 0 skipped (1 total tests) (base) ➜ ethereum git:(main) ✗ forge test --match-path test/foundry/unit/concrete/Bridgehub/l2transaction_base_cost.t.sol -vv
[⠔] Compiling... [⠘] Compiling 1 files with 0.8.20 [⠃] Solc 0.8.20 finished in 8.52s Compiler run successful!
Ran 1 test for test/foundry/unit/concrete/Bridgehub/l2transaction_base_cost.t.sol:ExperimentalBridgeTest [PASS] test_l2TransactionBaseCost() (gas: 203316) Logs: mockChainId 0 mockGasPrice 10 mockL2GasLimit 2000 mockL2GasPerPubdataByteLimit 15 mockL2TxnCost 55 Bound Result 2 calculatedL2TxnCost 55
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.45ms
Ran 1 test suite in 2.45ms: 1 tests passed, 0 failed, 0 skipped (1 total tests)
Assessed type
Invalid Validation