In the withdrawToken
function of the L2AssetRouter
contract, the _ensureTokenRegisteredWithNTV
function fails to properly return the assetId
, causing the subsequent _withdrawSender
function to fail.
L2AssetRouter
contract defines a function called withdrawToken
that is used to withdraw l2NativeToken
for a user.
However, there's a flaw in _ensureTokenRegisteredWithNTV
function that it doesn't return a valid assetId
, which then subsequently is used by _withdrawSender
function. It will retain its initial value of bytes32(0)
. As an invalid assetId
is provided, _withdrawSender
will inevitably fail, preventing the msg.sender
from receiving the expected token amount.
Below is an example scenario demonstrating the unfair revert:
Bob attempts to withdraw TokenA
from the L2AssetRouter
, but since TokenA
hasn’t been registered with the NativeTokenVault (NTV), he needs to call the withdrawToken
function to register the token and complete the withdrawal.
(Note: TokenA
must not be WETH, as it is not supported by NTV. Also, if TokenA was already registered, it'd fail too.)
However, the _ensureTokenRegisteredWithNTV
function fails to return a valid assetId registered with NTV, causing the withdrawal process to ultimately fail.
Modify the interface IL2AssetRouter
to include the definition of the public function withdrawToken
.
Put the test below inside L2Erc20TestAbstract.t.sol
and run test yarn test:foundry --match-test test_withdrawTokenL2AR -vvv
.
With invalid assetId
provided, particularly in cases where _l2NativeToken
has not yet been registered with the NativeTokenVault, _withdrawSender
will fail entirely. This prevents the msg.sender
from receiving the expected token amount, effectively halting the withdrawal process. Such scenarios could lead to disrupted user operations, potential loss of funds, and diminished trust in the system's reliability.
Manual Review, Foundry
Update _ensureTokenRegisteredWithNTV
function to make sure the assetId
is correctly assigned.
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.