Closed c4-bot-9 closed 6 months ago
razzorsec (sponsor) disputed
Calldata indexing is exclusive for the end bytes, i.e., [start:end) because index starts from 0.
Hence, _transaction.paymasterInput[0:4]
will be the 4 bytes selector from 0-3 bytes, and so the _transaction.paymasterInput[4:68]
will be the 64 bytes abi.encoded address token, uint256 minAllowance
from 4-67 bytes.
Hence, we agreed with the issue to be marked invalid
The Warden specifies that there is an overlap in the byte indices utilized by the function, however, as the Sponsor correctly points out, this is incorrect given that the ranges are non-inclusive in the upper end ([start,end)
using standard range notation).
alex-ppg marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-03-zksync/blob/main/code/system-contracts/contracts/libraries/TransactionHelper.sol#L374
Vulnerability details
Impact
Wrong Execution Due to Pay Master Input Overlap in TransactionHelper Contract
Proof of Concept
The code above shows how processPaymasterInput(...) is implemented in the TransactionHelper contract, a look at the first pointer from the code above shows that
bytes4(_transaction.paymasterInput[0:4]
was used to derivepaymasterInputSelector
, the problem is that later in the code in the second point instead of using_transaction.paymasterInput[5:68]
to derive token and minAllowance, the protocol used_transaction.paymasterInput[4:68]
, i.e [4:68] instead of [5:68], since the data for paymasterInputSelector is between 0 to 4, the value for token and minAllowance should start from5
not4
.Tools Used
Manual Review
Recommended Mitigation Steps
Protocol should make necessary adjustments to prevent input value overlap which could end up breaking protocol. The adjustment should be made as provided below
Assessed type
Context