Closed c4-submissions closed 11 months ago
bytes032 marked the issue as duplicate of #827
GalloDaSballo changed the severity to QA (Quality Assurance)
This previously downgraded issue has been upgraded by GalloDaSballo
GalloDaSballo marked the issue as not a duplicate
GalloDaSballo marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-10-zksync/blob/main/code/contracts/ethereum/contracts/zksync/facets/Mailbox.sol#L248 https://github.com/code-423n4/2023-10-zksync/blob/main/code/contracts/ethereum/contracts/zksync/facets/Mailbox.sol#L310 https://github.com/code-423n4/2023-10-zksync/blob/main/code/contracts/ethereum/contracts/zksync/facets/Mailbox.sol#L313
Vulnerability details
Impact
Loss of refund due to double address aliasing
Proof of Concept
Mailbox.requestL2Transaction
allows user to make transaction from L1 to L2. when making a transaction users a required to set the_refundrecipient
(If the L2 deposit finalization transaction fails, the_refundRecipient
will receive the_l2Value
.). it's explicitly stated that users can either specify an address or set address(0) to get the refund to themsg.sender
address. ifmsg.sender
is a contract the address has to be aliased inorder for the user to be able to make proper L2 tx requests. The issue is that when a user makes a request the local variablesender
is set depending if the caller is from anEOA
orcontract
. https://github.com/code-423n4/2023-10-zksync/blob/main/code/contracts/ethereum/contracts/zksync/facets/Mailbox.sol#L248sender
used as an argument to call the internal_requestL2Transaction
.L#310 checks if the
_refundRecipient
provided isaddress(0)
if so set the refund address to_sender
from the externalrequestL2Transaction
function which would have been aliased earlier if called from a contract. ThenL#312
checks if the address is a contract if true alias the address. This could result to double aliasing if the already aliasedsender
is a contract on L1. Looking atapplyL1ToL2Alias
it would add the offset twice since it being called twice on the address.This could result in double aliasing of the contract address which would lead to loss of refund.
Tools Used
Manual Review
Recommended Mitigation Steps
Assessed type
Error